Mezur
|
  |
| Joined: 29 Jun 2015 |
| Total Posts: 3040 |
|
|
| 14 Dec 2015 09:13 PM |
| I'm trying to make something that if I wear a specific tool and touch a brick, the tool will disappear and I will gain 5 gold on the leader stats. How do I do this? |
|
|
| Report Abuse |
|
|
Mezur
|
  |
| Joined: 29 Jun 2015 |
| Total Posts: 3040 |
|
| |
|
|
| 14 Dec 2015 09:15 PM |
Touch a specific brick with the tool?
1) What's the name of the specific brick? 2) Is the stat on the leaderboard called "Gold"? |
|
|
| Report Abuse |
|
|
|
| 14 Dec 2015 09:16 PM |
| Why do I feel like I saw this before use .Touched |
|
|
| Report Abuse |
|
|
Mezur
|
  |
| Joined: 29 Jun 2015 |
| Total Posts: 3040 |
|
|
| 14 Dec 2015 09:16 PM |
The specific name of the brick is called "Dirt" and yes "Gold" is on the leaderboard.
|
|
|
| Report Abuse |
|
|
|
| 14 Dec 2015 09:25 PM |
Put this in a LocalScript inside of the tool (WARNING: Untested, post if you get any errors)
= = = = = =
local tool = script.Parent local handle = tool:WaitForChild("Handle") local player = game.Players.LocalPlayer
function handleTouched(hit) if hit.Name == "Dirt" then player.leaderstats.Gold.Value = player.leaderstats.Gold.Value + 5 tool:Destroy() end end
= = = = = = |
|
|
| Report Abuse |
|
|
|
| 14 Dec 2015 09:26 PM |
WAIT NO, USE THIS ONE INSTEAD:
= = = = = =
local tool = script.Parent local handle = tool:WaitForChild("Handle") local player = game.Players.LocalPlayer
function handleTouched(hit) if hit.Name == "Dirt" then player.leaderstats.Gold.Value = player.leaderstats.Gold.Value + 5 tool:Destroy() end end
handle.Touched:connect(handleTouched)
= = = = = = |
|
|
| Report Abuse |
|
|
Mezur
|
  |
| Joined: 29 Jun 2015 |
| Total Posts: 3040 |
|
|
| 14 Dec 2015 09:27 PM |
| I want the tool to be named "Seeds" though |
|
|
| Report Abuse |
|
|
|
| 14 Dec 2015 09:29 PM |
Yeah the tool can be named whatever it wants, as long as the brick it touches is named Dirt.
You can change the name by clicking on the tool in Explorer and changing the Name property in Properties. |
|
|
| Report Abuse |
|
|
hkep
|
  |
| Joined: 19 Jul 2014 |
| Total Posts: 550 |
|
|
| 14 Dec 2015 09:33 PM |
local Part = script.Parent;
Part.Touched:connect(function(Hit) local Char = Hit.Parent; local Hum,Tool = Char:FindFirstChild("Humanoid"),Char:FindFirstChild("Seeds"); if Hum and Tool then local Player = game.Players:FindFirstChild(Char.Name); local S = Player.leaderstats.Gold; Tool:Destroy(); S.Value = (S.Value + 5); end; end); |
|
|
| Report Abuse |
|
|
hkep
|
  |
| Joined: 19 Jul 2014 |
| Total Posts: 550 |
|
|
| 14 Dec 2015 09:34 PM |
| Put my code in a 'Script' under an object 'Part'. |
|
|
| Report Abuse |
|
|
Mezur
|
  |
| Joined: 29 Jun 2015 |
| Total Posts: 3040 |
|
|
| 14 Dec 2015 09:35 PM |
| what do i title the tool though |
|
|
| Report Abuse |
|
|
Mezur
|
  |
| Joined: 29 Jun 2015 |
| Total Posts: 3040 |
|
| |
|
Mezur
|
  |
| Joined: 29 Jun 2015 |
| Total Posts: 3040 |
|
| |
|