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 |
|
|
|
| 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 |
|
|
|
| 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 |
|
|
|
| 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
|
  |
| 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
|
  |
| 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
|
  |
| Joined: 22 Mar 2012 |
| Total Posts: 8811 |
|
| |
|
|
| 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
|
  |
| Joined: 22 Mar 2012 |
| Total Posts: 8811 |
|
|
| 20 Jan 2015 05:44 PM |
Got one that works perfectly! Thank you guys! <3 |
|
|
| Report Abuse |
|
|
|
| 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 |
|
|
|
| 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
|
  |
| Joined: 22 Mar 2012 |
| Total Posts: 8811 |
|
|
| 20 Jan 2015 05:50 PM |
| A bullet, as in any parts? |
|
|
| Report Abuse |
|
|
|
| 20 Jan 2015 05:59 PM |
"null" @cody
null is js nil is lua |
|
|
| Report Abuse |
|
|
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 |
|
|
|
| 20 Jan 2015 06:01 PM |
@chim; and is there a problem with doing so?
::_::goto_ |
|
|
| Report Abuse |
|
|
chimmihc
|
  |
| Joined: 01 Sep 2014 |
| Total Posts: 17143 |
|
| |
|
|
| 20 Jan 2015 06:05 PM |
the correct answer would've been no
::_::goto_ |
|
|
| Report Abuse |
|
|
chimmihc
|
  |
| Joined: 01 Sep 2014 |
| Total Posts: 17143 |
|
| |
|
|
| 20 Jan 2015 06:08 PM |
@Defleure dont be mean to chim!1!1!!!11!!
"I like to program." - Bosswalrus |
|
|
| Report Abuse |
|
|
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 |
|
|