I am currently trying to make a sandbox tycoon and I put a numbervalue inside of the money (money is like the ore in Miners Haven) that is the value of the money, but I cannot find a way to make it where when it touches a certain part it gets the value from the numbervalue inside of the money and adds it to the Cash value inside of localplayer.leaderstats Please help! This is what I have tried
local repStorage = game:GetService("ReplicatedStorage")
function onTouched(hit)
if hit.Name == "Cash" then
game.Players.LocalPlayer.leaderstats.Cash.value = game.Players.LocalPlayer.leaderstats.Cash.value + hit.Value.Value
hit:remove()
end
end
script.Parent.Touched:connect(onTouched)
I am aware that localplayer does not work inside of server scripts, but this is an example of what i need to happen

6 comments
Can you post the code you've tried?
I have tried with remote events but i suck with them, how do i post script here in a readable way?
When you ask or edit a question, there’s a blue circle with text that says “Lua” in it. Click it and copy paste your code between the squiggly lines that appear.
I have tried with remote events but i do not have the script i tried because when it didnt work i then tried what is above
bump
Local Scripts don't work in workspace.