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

Quest system not rewarding points, help?

Asked by 6 years ago

I've made a quest system and it works fine. Only downside is that I'm not able to add a reward so if a player completes a quest it just completes and doesn't give any leaderstats points. I've altered the script a bit and it runs fine in studio but when I tested it on it's own then it doesn't give me any points. Heres the script:

script.Parent.Touched:connect(function(k)
    if k and k.Parent.Humanoid and game.Players[k.Parent.Name].Quest.Value == "go touch the other brik" then
        game.Players[k.Parent.Name].Quest.Value = "[Completed]"
        wait(1.1) 
         game.Players.LocalPlayer.leaderstats.Neutros.Value = game.Players.LocalPlayer.leaderstats.Neutros.Value + 200
        end
end)

1 answer

Log in to vote
0
Answered by 6 years ago

you are trying to get localplayer in a server script ? lol Also it's better to use the GetPlayerFromCharacter function cause it's possible that the character name could have been changed

script.Parent.Touched:connect(function(touchedpart)
    local player = game.Players:GetPlayerFromCharacter(touchedpart.Parent)
    if player then
        if player.Quest.Value == "go touch the other brik" then
            player.Quest.Value = "[Completed]"
            player.leaderstats.Neutros.Value = player.leaderstats.Neutros.Value + 200
        end
    end
end)
0
GetPlayerFromCharacter is mainly better because it only detects players, and not just every single thing that has a humanoid inside it. CootKitty 311 — 6y
0
Also, use :Connect as :connect is deprecated. awfulszn 394 — 6y
Ad

Answer this question