My script won’t work. Can anybody tell me why? (It’s for selling strength to get cash in a sim)
Script: (I don’t know how to do it like other people do it)
local part = script.Parent
part.Touched:Connect(function(hit)
local h = hit.Parent:FindFirstChild(“Humanoid”)
if h then
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if player then
local leaderstats = player:WaitForChild(“leaderstats”)
local money = leaderstats.Cash
local selling = leaderstats.Strength
if selling.Value >= 0 then
money.Value = money.Value + selling.Value*1
selling.Value = 0
end
end
end
end)
local part = script.Parent
part.Touched:Connect(function(hit)
local h = hit.Parent:FindFirstChild(“Humanoid”)
if h then
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if player then
local leaderstats = player:WaitForChild(“leaderstats”)
local money = leaderstats.Cash
local selling = leaderstats.Strength
if selling.Value >= 0 then
money.Value += selling.Value
selling.Value = 0
end
end
end
end)
local part = script.Parent
local debounce = false
part.Touched:Connect(function(hit)
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if player and debounce == false then
debounce = true
local leaderstats = player:WaitForChild(“leaderstats”)
local money = leaderstats.Cash
local selling = leaderstats.Strength
if selling.Value >= 0 then
money.Value += selling.Value
selling.Value = 0
end
debounce = false
end
end)
I made the script better, also the problem could be that you don’t have a leaderstats