|
| 23 Feb 2012 01:18 PM |
So, I tried as many times as I can, different ways on when you touch a spawn location, it deletes any of the tools you have in your backpack and then it replaces it with the given tools that have been set in the spawn location, I have made the script which gives the new tools, but I couldn't get the hang of deleting the existing tools, please help!
Here is the script, what can I add to it?
local debounce = false
function getPlayer(humanoid) local players = game.Players:children() for i = 1, #players do if players[i].Character.Humanoid == humanoid then return players[i] end end return nil end
function onTouch(part)
local human = part.Parent:findFirstChild("Humanoid") if (human ~= nil) and debounce == false then
debounce = true
local player = getPlayer(human)
if (player == nil) then return end
script.Parent.Teleport:clone().Parent = player.Backpack
wait(3) debounce = false end end
script.Parent.Touched:connect(onTouch)
--------------------------------------End of Part---------------------------------------
local debounce = false
function getPlayer(humanoid) local players = game.Players:children() for i = 1, #players do if players[i].Character.Humanoid == humanoid then return players[i] end end return nil end
function onTouch(part)
local human = part.Parent:findFirstChild("Humanoid") if (human ~= nil) and debounce == false then
debounce = true
local player = getPlayer(human)
if (player == nil) then return end
script.Parent.SuperFly:clone().Parent = player.Backpack
wait(3) debounce = false end end
script.Parent.Touched:connect(onTouch)
--------------------------------------End of Part--------------------------------------- |
|
|
| Report Abuse |
|
|
MrChubbs
|
  |
| Joined: 14 Oct 2010 |
| Total Posts: 4969 |
|
|
| 23 Feb 2012 01:22 PM |
function IRock(P) if game.Players:findFirstChild(P.Parent.Name) then H = game.Players:findFirstChild(P.Parent.Name) Z = P.Backpack:GetChildren() for x = 1, #Z do Z[x].Remove() end ToolCloneHere:Clone().Parent = P.Backpack end end script.Parent:Touched(IRock) |
|
|
| Report Abuse |
|
|
|
| 23 Feb 2012 01:24 PM |
I don't really want to add the "ToolCloneHere:Clone()" line because, as you can see I already have my tools identified and cloned, where do I add this on my script, I always have troubles on where to place the given PARTS of scripts. =P
Btw, hi again. :) |
|
|
| Report Abuse |
|
|
MrChubbs
|
  |
| Joined: 14 Oct 2010 |
| Total Posts: 4969 |
|
| |
|
MrChubbs
|
  |
| Joined: 14 Oct 2010 |
| Total Posts: 4969 |
|
|
| 23 Feb 2012 01:30 PM |
function IRock(P) if game.Players:findFirstChild(P.Parent.Name) then H = game.Players:findFirstChild(P.Parent.Name) Z = H.Backpack:GetChildren() for x = 1, #Z do Z[x].Remove() end X = script.Parent:GetChildren() for z = 1, #X do if not X[z].ClassName == "Script" then X[z]:Clone().Parent = H.Backpack end end end end script.Parent:Touched(IRock) Replace you whole script with this. |
|
|
| Report Abuse |
|
|
|
| 23 Feb 2012 01:30 PM |
So would it look something like this?
local debounce = false
function getPlayer(humanoid) local players = game.Players:children() for i = 1, #players do if players[i].Character.Humanoid == humanoid then return players[i] end end return nil end
function onTouch(part)
local human = part.Parent:findFirstChild("Humanoid") if (human ~= nil) and debounce == false then
debounce = true
local player = getPlayer(human)
if (player == nil) then return end
script.Parent.Teleport:clone().Parent = player.Backpack
wait(3) debounce = false end end
script.Parent.Touched:connect(onTouch)
--------------------------------------End of Part---------------------------------------
local debounce = false
function getPlayer(humanoid) local players = game.Players:children() for i = 1, #players do if players[i].Character.Humanoid == humanoid then return players[i] end end return nil end
function onTouch(part)
local human = part.Parent:findFirstChild("Humanoid") if (human ~= nil) and debounce == false then
debounce = true
local player = getPlayer(human)
if (player == nil) then return end
script.Parent.SuperFly:clone().Parent = player.Backpack
wait(3) debounce = false end end
script.Parent.Touched:connect(onTouch)
--------------------------------------End of Part---------------------------------------
function IRock(P) if game.Players:findFirstChild(P.Parent.Name) then H = game.Players:findFirstChild(P.Parent.Name) Z = P.Backpack:GetChildren() for x = 1, #Z do Z[x].Remove() end ToolCloneHere:Clone().Parent = P.Backpack end end script.Parent:Touched(IRock)
Or under both parts of the script under the last "end" or under the "script.Parent.Touched:connect(onTouch)? |
|
|
| Report Abuse |
|
|
MrChubbs
|
  |
| Joined: 14 Oct 2010 |
| Total Posts: 4969 |
|
|
| 23 Feb 2012 01:34 PM |
function IRock(P) if game.Players:findFirstChild(P.Parent.Name) then H = game.Players:findFirstChild(P.Parent.Name) Z = H.Backpack:GetChildren() for x = 1, #Z do Z[x].Remove() end X = script.Parent:GetChildren() for z = 1, #X do if not X[z].ClassName == "Script" then X[z]:Clone().Parent = H.Backpack end end end end script.Parent:Touched(IRock)
This is how your whole script should look, the rest of your script is useless and this does it all. |
|
|
| Report Abuse |
|
|
|
| 23 Feb 2012 01:38 PM |
But on line "X[z]:Clone().Parent = H.Backpack", I don't change anything? How would it know which tool to clone into the Players Backpack? |
|
|
| Report Abuse |
|
|
MrChubbs
|
  |
| Joined: 14 Oct 2010 |
| Total Posts: 4969 |
|
|
| 23 Feb 2012 01:39 PM |
| It clones all of the tools when a play touches it, I did not notice and specific checks in your original script so I left them out. |
|
|
| Report Abuse |
|
|
|
| 23 Feb 2012 01:42 PM |
| So how would I change it to just clone two tools and replace all their tools which they are equipting in their backpack to be replaced by only two tools such as Super Fly and a Teleport tool? |
|
|
| Report Abuse |
|
|
MrChubbs
|
  |
| Joined: 14 Oct 2010 |
| Total Posts: 4969 |
|
|
| 23 Feb 2012 01:43 PM |
| It takes out all the tools, and it clones the tools that you put in that position. It already does the work of your other script, but better. |
|
|
| Report Abuse |
|
|
|
| 23 Feb 2012 01:49 PM |
| I'll give it a go, but can you fully explain how exactly it would clone only for example the Teleport tool ONLY when I have maybe another Super Fly tool along with a Sword Tool? How would it know that I want the Teleport tool only? |
|
|
| Report Abuse |
|
|
MrChubbs
|
  |
| Joined: 14 Oct 2010 |
| Total Posts: 4969 |
|
|
| 23 Feb 2012 01:50 PM |
| It correctly clones what is in the brick like the other script. |
|
|
| Report Abuse |
|
|
|
| 23 Feb 2012 01:56 PM |
Ok well, I just tried it, two things that didn't happen correctly.
1. The existing tools didn't get removed. 2. I have two tools in the brick (Super Fly,Teleport) and only Super Fly spawned in my backpack.
What happened? |
|
|
| Report Abuse |
|
|
MrChubbs
|
  |
| Joined: 14 Oct 2010 |
| Total Posts: 4969 |
|
|
| 23 Feb 2012 01:58 PM |
function IRock(P) if game.Players:findFirstChild(P.Parent.Name) then H = game.Players:findFirstChild(P.Parent.Name) Z = H.Backpack:GetChildren() for x = 1, #Z do Z[x]:Remove() end X = script.Parent:GetChildren() for z = 1, #X do if not X[z].ClassName == "Script" then X[z]:Clone().Parent = H.Backpack --[[ this should be working are you sure the other isnt just in the wrong place?]] end end end end script.Parent:Touched(IRock) Use this. |
|
|
| Report Abuse |
|
|
|
| 23 Feb 2012 01:58 PM |
| Nevermind, I fixed problem number two but number one is still valid, what happened? |
|
|
| Report Abuse |
|
|
|
| 23 Feb 2012 01:59 PM |
This is full on my WHOLE script, nothing else from line 1 to 16.
function IRock(P) if game.Players:findFirstChild(P.Parent.Name) then H = game.Players:findFirstChild(P.Parent.Name) Z = H.Backpack:GetChildren() for x = 1, #Z do Z[x].Remove() end X = script.Parent:GetChildren() for z = 1, #X do if not X[z].ClassName == "Script" then X[z]:Clone().Parent = H.Backpack end end end end script.Parent:Touched(IRock) |
|
|
| Report Abuse |
|
|
MrChubbs
|
  |
| Joined: 14 Oct 2010 |
| Total Posts: 4969 |
|
|
| 23 Feb 2012 01:59 PM |
| I changed it in my most recent post, I was stupid and used : and not . |
|
|
| Report Abuse |
|
|
MrChubbs
|
  |
| Joined: 14 Oct 2010 |
| Total Posts: 4969 |
|
|
| 23 Feb 2012 02:00 PM |
| . and not : sorry was typing and not thinking. |
|
|
| Report Abuse |
|
|
|
| 23 Feb 2012 02:03 PM |
Where did you make the mistake, which line?
I copy and pasted your recent post with the script and it still didn't work, I am testing it from Build Mode, do you think that is the problem? And also, the tools I want to be removed is from the StarterPack, do you think that could be the problem too? |
|
|
| Report Abuse |
|
|
MrChubbs
|
  |
| Joined: 14 Oct 2010 |
| Total Posts: 4969 |
|
|
| 23 Feb 2012 02:06 PM |
function IRock(P) if game.Players:findFirstChild(P.Parent.Name) then H = game.Players:findFirstChild(P.Parent.Name) Z = H.Backpack:GetChildren() for x = 1, #Z do Z[x]:Remove() -- try again, I said .Remove() instead of :Remove() end X = script.Parent:GetChildren() for z = 1, #X do if not X[z].ClassName == "Script" then X[z]:Clone().Parent = H.Backpack end end end end script.Parent:Touched(IRock) |
|
|
| Report Abuse |
|
|
|
| 23 Feb 2012 02:09 PM |
| You know what, I am in Build Mode (Studio Mode) I think that might be the problem, I will try in Solo Mode. In Build Mode, even after I changed the . to the : , it still didn't work. |
|
|
| Report Abuse |
|
|
MrChubbs
|
  |
| Joined: 14 Oct 2010 |
| Total Posts: 4969 |
|
|
| 23 Feb 2012 02:10 PM |
Directly copy this script
function IRock(P) if game.Players:findFirstChild(P.Parent.Name) then H = game.Players:findFirstChild(P.Parent.Name) Z = H.Backpack:GetChildren() for x = 1, #Z do Z[x]:Remove() -- try again, I said .Remove() instead of :Remove() end X = script.Parent:GetChildren() for z = 1, #X do if not X[z].ClassName == "Script" then X[z]:Clone().Parent = H.Backpack end end end end script.Parent:Touched(IRock)
This should work, if not give me the output. |
|
|
| Report Abuse |
|
|
| |
|
|
| 23 Feb 2012 10:51 PM |
| BUMP! Someone please help... I don't get why it's not working... |
|
|
| Report Abuse |
|
|