Having a 'LocalPlayer' inside a server script will not work among in-game play. The script below is a modified version, which checks to see the player for touching the brick and checks the name. The script below is supposed to be put into the brick and in a server script, not a local script.
function onTouch(hit)
local check = hit.Parent:FindFirstChild("Humanoid")
if check ~= nil and script.Parent.Name == "MoneyBrick" then
local user = game.Players:GetPlayerFromCharacter(hit.Parent)
local stats = user:FindFirstChild("leaderstats")
if stats ~= nil then
local money = stats:FindFirstChild("Money")
money.Value = money.Value +1
script.Parent:Destroy()
end
else
print("Not named correctly.")
end
end
script.Parent.Touched:connect(onTouch)
4 comments
So I replaced this script with the old one and in Output it just said "Not named correctly." repeatedly even though the bricks are called MoneyBrick
what do I do
Can you send a screenshot link of what you are specifically trying to do?
Ok I made a picture explaining the problem: https://drive.google.com/file/d/0B5Sa_dRUhnR9ZV9JeFBqaG15alU/view?usp=sharing