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

Brick awarding point help? [Solved]

Asked by 10 years ago

Hey there biocommand here, I am working in some games and have the same problem with this, what I am trying to do is a brick that awards points when the player steps on it (Not player points) and it´s not working I used the one from roblox wiki and it might be outdated, heres the script:


local enabled = true game.Players.PlayerAdded:connect(function(player) local leader, score = Instance.new('IntValue', player), Instance.new('IntValue') leader.Name = 'leaderstats' score.Name = 'Score' score.Parent = leader end) Workspace.Button.Touched:connect(function(hit) local p = game.Players:FindFirstChild(hit.Parent.Name) if pl and enabled == true then enabled = false p.leaderstats.Score.Value = p.leaderstats.Score.Value + 5 wait(20) enabled = true end end)

here´s the leaderboard if the problem is with that

game.Players.PlayerAdded:connect(function(player)
    local leader, score = Instance.new('IntValue', player), Instance.new('IntValue')
    leader.Name = 'leaderstats'
    score.Name = 'Score'
    score.Parent = leader
end)

Also I put both with scripts, not local scripts.

1 answer

Log in to vote
1
Answered by
Link43758 175
10 years ago

There are two things wrong with your code:

local enabled = true

game.Players.PlayerAdded:connect(function(player)
    local leader, score = Instance.new('IntValue', player), Instance.new('IntValue')
    leader.Name = 'leaderstats'
    score.Name = 'Score'
    score.Parent = leader
end)

Workspace.Button.Touched:connect(function(hit)
    local p = game.Players:FindFirstChild(hit.Parent.Name) -- If there is not a player that has the name of a part's parent that touches button, then the script will error. Check if humanoid is in hit's parent.
    if pl and enabled == true then -- pl is undefined. You probably meant p.
        enabled = false
        p.leaderstats.Score.Value = p.leaderstats.Score.Value + 5
        wait(20)
        enabled = true
    end
end)

Hope I've helped!

0
Thanks I already corrected the pl, but what do I do in the first error? I mean how do I correct that? I am new to scripting biocommand 30 — 10y
0
Whoops, nevermind. You should be fine as long as you've fixed that error. I just saw that you were using FindFirstChild. Is the script working? Are there any errors in output? I'd be glad to help Link43758 175 — 10y
0
its working fine :D thank you very much :D biocommand 30 — 10y
0
Mhm - no problem! Link43758 175 — 10y
Ad

Answer this question