Ok I have my script but it is not working. I am trying to give the user 100 cash when they touch the brick and then wait an hour to receive 100 more cash.
Here is my leaderboard script.
game.Players.PlayerAdded:Connect(function(plr)
local leader = Instance.new(“Folder”, plr)
leader.name = ‘leaderstats’
local cash = Instance.new(“IntValue”, leader)
cash.Name = ‘Cash’
end)
Here is my touch script for money:
db = false
script.Parent.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild(“Humanoid”) then
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if db == false then
db = true
player.leaderstats.cash.Value = player.leader.cash.Value + 100
wait(3600)
player.leaderstats.cash.Value = player.leader.cash.Value + 100
db = false
end
end
end)
It is not working, anyone know the error?
Thanks in advance!
he has that just not in the code block, and remove the .Name cause that would be trying to identify the model object from the stringname, if you were to do it like then it would just be the
script.Parent.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild(“Humanoid”) then
local player = game.Players:FindFirstChild(hit.Parent.Name)
if db == false then
db = true
player.leader.cash.Value = player.leader.cash.Value + 100
wait(3600)
player.leader.cash.Value = player.leadercash.Value + 100
db = false
end
end
script.Parent.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild(“Humanoid”) then
local player = game.Players:FindFirstChild(hit.Parent.Name)
if db == false then
db = true
player.leader.cash.Value = player.leader.cash.Value + 100
wait(3600)
player.leader.cash.Value = player.leadercash.Value + 100
db = false
end
end
okay so basically you are trying to use a hierarchy type system, The guy before made a mistake and removed it so sorry for that confusion you had it almost right the first time you only just had one word mistyped and that was all
game.Players.PlayerAdded:Connect(function(plr)
local leader = Instance.new(“Folder”, plr)
leader.name = ‘leaderstats’
local cash = Instance.new(“IntValue”, leader)
cash.Name = ‘Cash’
end)
so Above here you are creating something called “leaderstats” under the player
db = false
script.Parent.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild(“Humanoid”) then
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if db == false then
db = true
player.leaderstats.cash.Value = player.leaderstats.cash.Value + 100
wait(3600)
db = false
end
end
so basically you only had the one original error in the script where you typed player.leader.cash when its player.leaderstats.cash
db = false
script.Parent.Touched:connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if db == false then
db = true
script.Parent.Transparency = 1
script.Parent.CanCollide = false
player.leaderstats.cash.Value = player.leaderstats.cash.Value + 50
wait (3600)
script.Parent.Transparency = 0
script.Parent.CanCollide = true
db = false
end
end
end)
You have to do:
player.leaderstats.cash.Value = player.leaderstats.cash.Value + 100
What you’re doing is:
player.leaderstats.cash.Value = player.leader.cash.Value + 100
The examples provided above should work fine. Leaderboard goes into ServerScriptService and the actual “Touch script” goes into your part in workspace.