Hello, I am trying to make so when you step on a part you sell the stone you have and gets coins however it gives me an error leaderstats is not a valid member of Model “Workspace.slllJakob” How do I fix this?
local debounce = false
local player = game:GetService("Players")
script.Parent.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
if not debounce then
debounce = true
local Stone = player.leaderstats.Stone.Value
local Cash = player.leaderstats.Cash.Value
print(hit.Parent)
debounce = false
end
end
end)
local debounce = false
local player = game:GetService("Players").LocalPlayer
script.Parent.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
if not debounce then
debounce = true
local Stone = player.leaderstats.Stone.Value
local Cash = player.leaderstats.Cash.Value
print(hit.Parent)
debounce = false
end
end
end)
local debounce = false
script.Parent.Touched:Connect(function(hit)
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if player and not debounce then
debounce = true
local Stone = player.leaderstats.Stone.Value
local Cash = player.leaderstats.Cash.Value
task.wait(0.25)
debounce = false
end
end)
Also in this script, just incase you didn’t know, setting the Stone and Cash variables will not directly set the leaderstats, because I just noticed the script doesn’t change any leaderstats yet.