generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: Can anyone make me this simple 20'ish lined script?

Previous Thread :: Next Thread 
Defleure is not online. Defleure
Joined: 22 Mar 2012
Total Posts: 8811
20 Jan 2015 05:32 PM
A script that works sort of like a tool giver but using replicatedstorage to grab the tool.

It works when you touch it, like a giver...
To grab the part it's:

script.Parent.Parent.Parent.Parent.ReplicatedStorage.Tools.Doughnut



Report Abuse
KOTwarrior is not online. KOTwarrior
Joined: 13 Jun 2012
Total Posts: 4376
20 Jan 2015 05:36 PM
put in the part


tool = game.ReplicatedStorage.Tools.Doughnut;
script.Parent.Touched:connect(function(h)
local s = pcall(function() return h.Parent.Humanoid end);
if s then
tool:Clone().Parent = game.Players[h.Parent.Name].Backpack;
end;
end);
Report Abuse
cody123454321 is not online. cody123454321
Joined: 21 Nov 2009
Total Posts: 5408
20 Jan 2015 05:38 PM
-- TODO: Insert this script into a part... the "Giver"
-- Untested

local RS = game:GetService("ReplicatedStorage")

local to_give = "Example Weapon Name"
local amount = 1
local grab_delay = 1

--

local bin = script.Parent
local deb = true
bin.Touched:connect(function(hit)
if(not hit.Parent or not hit.Parent:IsA("Model") or not hit.Parent:FindFirstChild("Humanoid"))then
wait()
return
end
if(deb)then
deb = not deb
for i=1, amount do
local p = RS:FindFirstChild(to_give)
if(p)then
p:Clone().Parent = game.Players:GetPlayerFromCharacter(hit.Parent).Backpack
end
end
wait(grab_delay)
deb = not deb
end
end)

Report Abuse
fishguy100 is not online. fishguy100
Joined: 16 Feb 2013
Total Posts: 3679
20 Jan 2015 05:38 PM
local parttotouch = workspace:WaitForChild('Part') -- Name of the part

function PlayerTouchedPart(hit.Parent)
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if (player) then
if not player.Backpack.Doughnut then
game.ReplicatedStorage.Tools.Doughnut:Clone().Parent = player.Backpack
end
end
end

parttotouch.Touched:connect(PlayerTouchedPart)


--Hope this works :D
Report Abuse
chimmihc is not online. chimmihc
Joined: 01 Sep 2014
Total Posts: 17143
20 Jan 2015 05:39 PM
OMG you guys putting the ;'s after the lines annoys me soooooo much!! this is Lua you dont need to do it!!


AHFOEIFALHFEIUNKCMEAIIFHIUEHFADSOIAHFIEOWNIUCNYBUURAFOUGAFUHIEHFKFNEAOBY!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!


AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAH!


lel
Report Abuse
Defleure is not online. Defleure
Joined: 22 Mar 2012
Total Posts: 8811
20 Jan 2015 05:41 PM
@Kot

Is there a way to control the amount it gives you? I touched it once and got my backpack full of them!
Report Abuse
Defleure is not online. Defleure
Joined: 22 Mar 2012
Total Posts: 8811
20 Jan 2015 05:42 PM
@Chim
You're annoying.
Report Abuse
cody123454321 is not online. cody123454321
Joined: 21 Nov 2009
Total Posts: 5408
20 Jan 2015 05:42 PM
It's not only a habit, but it does mark the end of lines.

Thinks that leak over lines like

local a = (example and tenery or operator)
or (example2 and tenery2 or operator2)
and (example3 and tenery2 or operator3 + operator4)
Report Abuse
Defleure is not online. Defleure
Joined: 22 Mar 2012
Total Posts: 8811
20 Jan 2015 05:44 PM
Got one that works perfectly!
Thank you guys! <3
Report Abuse
KOTwarrior is not online. KOTwarrior
Joined: 13 Jun 2012
Total Posts: 4376
20 Jan 2015 05:44 PM
tool = game.ReplicatedStorage.Tools.Doughnut;
db = true;

script.Parent.Touched:connect(function(h)
local s = pcall(function() return h.Parent.Humanoid end);
if s and db then
db = false;
tool:Clone().Parent = game.Players[h.Parent.Name].Backpack;
wait(2);
db = true;
end;
end);
Report Abuse
cody123454321 is not online. cody123454321
Joined: 21 Nov 2009
Total Posts: 5408
20 Jan 2015 05:49 PM
@KOT

Sometimes when bullets hit the part, their parents can be null.

You must insert a check for this...

if(hit.Parent)then

end

I like what you're trying to do here, but just because there is a humanoid doesn't mean that there is a player. If the player was not found by calling game.Players[index] then it will error and break the script. Use game.Players:GetPlayerFromCharacter(), set the result to a variable. After that use the variable as a check if there is a player and use the player.
Report Abuse
Defleure is not online. Defleure
Joined: 22 Mar 2012
Total Posts: 8811
20 Jan 2015 05:50 PM
A bullet, as in any parts?
Report Abuse
xolbStudios is not online. xolbStudios
Joined: 05 Nov 2009
Total Posts: 504
20 Jan 2015 05:59 PM
"null" @cody

null is js
nil is lua
Report Abuse
chimmihc is not online. chimmihc
Joined: 01 Sep 2014
Total Posts: 17143
20 Jan 2015 06:00 PM
you do know that you don't NEED to mark the end of lines in Lua right?
Report Abuse
KOTwarrior is not online. KOTwarrior
Joined: 13 Jun 2012
Total Posts: 4376
20 Jan 2015 06:01 PM
@chim; and is there a problem with doing so?


::_::goto_
Report Abuse
chimmihc is not online. chimmihc
Joined: 01 Sep 2014
Total Posts: 17143
20 Jan 2015 06:01 PM
yes
Report Abuse
KOTwarrior is not online. KOTwarrior
Joined: 13 Jun 2012
Total Posts: 4376
20 Jan 2015 06:05 PM
the correct answer would've been no


::_::goto_
Report Abuse
chimmihc is not online. chimmihc
Joined: 01 Sep 2014
Total Posts: 17143
20 Jan 2015 06:06 PM
I will not give in...
Report Abuse
bosswalrus is not online. bosswalrus
Joined: 04 Jan 2013
Total Posts: 5430
20 Jan 2015 06:08 PM
@Defleure dont be mean to chim!1!1!!!11!!

"I like to program." - Bosswalrus
Report Abuse
JoshD43 is not online. JoshD43
Joined: 03 Jul 2012
Total Posts: 1390
20 Jan 2015 06:13 PM
"script.Parent.Parent.Parent.Parent.ReplicatedStorage.Tools.Doughnut"

e.e

Aegis Accord | Spectrum FPS
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image