Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why wont it give cash?? what's wrong here?

Asked by 10 years ago

Title says it all... Here's the script:

script.Parent.Touched:connect(function(hit)
    humanoid = hit.Parent:FindFirstChild("Humanoid")
    if humanoid ~= nil then
        hit.Parent.leaderstats.Cash.Value = hit.Parent.leaderstats.Cash.Value +script.Parent.Cash.Value
        script.Parent.Cash.Value = 0
    end
end)

Output: 20:26:36.266 - leaderstats is not a valid member of Model 20:26:36.268 - Script 'Workspace.Model.ToCollect.Script', Line 4 20:26:36.269 - Stack End 20:26:36.270 - Disconnected event because of exception

1 answer

Log in to vote
0
Answered by 10 years ago

Btw this is not tested.

What this would I hope do is give cash if the cash value is inside leaderstats and i hope you inserted leaderstats into the player and it will double the cash and if you wanna change the cash recieved or taken there is a comment there

and then will wait 5 seconds before repeating process

local db = true
local coolingtime = 5
script.Parent.Touched:connect(function(hit)
    if not db then return end   
    local human = hit.Parent:findFirstChild("Humanoid")
    if human then
    db = false
    local cash = game.Players:GetPlayerFromCharacter(hit.Parent).leaderstats.Cash
    cash.Value = cash.Value + cash.Value --change here to change cash given
        wait(coolingtime)
    end
end)
0
Naa, Wrong thing. It's not continuous every 5 seconds. Its when a player touches a brick, the brick has a value, That value adds to the leaderstat AND that value get reset to 0. and Yes, there is a "Cash" IntValue in "leaderstats" fahmisack123 385 — 10y
Ad

Answer this question