|
| 23 Jul 2015 01:04 PM |
I have a problem. I'm trying to make a script , that if a "Minion" touch a tree it will cut it down and give the ressources to their Master (The Player). It's work in singleplayer but not in multiplayer.
Here's the script
Tree = script.Parent Chopped = Tree.Chopped Stump = Tree.Stump Cant = 0
Stump.Touched:connect(function(hit) local Worker = game.Workspace.Worker local Master = game.Workspace.Worker:FindFirstChild("Master") local Cutter = game.Players:FindFirstChild(Master.Value) local Wood = Cutter:FindFirstChild("Wood") Wood = Cutter:FindFirstChild("Wood") local hum = hit and hit.Parent and hit.Parent:FindFirstChild("Humanoid") if hum.Parent == Worker then if Cant == 0 then Cant = 1 repeat wait() until Tree:FindFirstChild("Trunk") and Tree:FindFirstChild("Leaves") local Trunk = Tree.Trunk local Leaves = Tree.Leaves Leaves:Destroy() Trunk:Destroy() Wood.Value = Wood.Value + 1 Chopped.Value = 1 wait(20.1) Cant = 0 end end end) |
|
|
| Report Abuse |
|
|
| |
|
| |
|
| |
|
Klink45
|
  |
| Joined: 06 Jun 2011 |
| Total Posts: 26054 |
|
|
| 23 Jul 2015 02:52 PM |
Idk, make sure the minion's name is "Worker," also if there are multiple minions then you're only finding one of them.
u sicko! |
|
|
| Report Abuse |
|
|
|
| 23 Jul 2015 03:01 PM |
| yeah but it why I'm trying to ask how I could find all of them and use one of them selectivily with their master value. |
|
|
| Report Abuse |
|
|
Klink45
|
  |
| Joined: 06 Jun 2011 |
| Total Posts: 26054 |
|
|
| 23 Jul 2015 03:15 PM |
Here's an example of getting the minions and doing something with them:
local Minions = game.Workspace.Minions:GetChildren() --Minions is a model and the player's are the model's children, which means the players are inside of the model.
for i,v in pairs (Minions) do --v is each child of Minions. if v.Torso then --Code!!!!!!! end end
Also read: wiki.roblox.com/index.php?title=GetChildren wiki.roblox.com/index.php?title=Pairs#pairs
u sicko! |
|
|
| Report Abuse |
|
|
|
| 23 Jul 2015 06:05 PM |
| Could you explain me how pairs work please O_o . I've read the forum topic and I can't get it. I want to make that if a minion touch a tree it will remove the tree and give +1 wood in a value that the owner of the minion have. |
|
|
| Report Abuse |
|
|
| |
|