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

Why won't this work?? [SOLVED]

Asked by 9 years ago

This code is pretty easy, but doesn't work for some reason D:

player = script.Parent.Parent
player.leaderstats.Stage.Value.Changed:connect(function()
    game:GetService("PointsService"):AwardPoints(player.userId, math.random(1,10))
end)

--[[OUTPUT:
attempt to index field 'Value' (a number value)
]]

Also, this code won't even make the message appear D:

game.Players.PlayerAdded:connect(function(player)
    player.Chatted:connect(function(msg)
        if msg == ":CheckPoints" then
            a = Instance.new("Message")
            a.Parent = player
            a.Text = "There are ".. game:GetService("PointsService"):GetAwardablePoints().." Player Points available"
        elseif msg == ":CheckMyPoints" then
            a = Instance.new("Message")
            a.Parent = player
            gamebalance = game:GetService("PointsService"):GetGamePointBalance(player.userId)
            totalpoints = game:GetService("PointsService"):GetPointBalance(player.userId)
            a.Text = "You Earnt "..gamebalance.." Points in this game and a total of "..totalpoints.." Player Points"
        end
    end)
end)
0
Message script: Try making it into local script and make "a" Parent game.Workspace.CurrentCamera (LocalPlayer's camera) fireboltofdeath 635 — 9y
0
Can't. Player Points fahmisack123 385 — 9y

1 answer

Log in to vote
0
Answered by 9 years ago
player = script.Parent.Parent
player.leaderstats.Stage.Changed:connect(function() -- .Value removed
    game:GetService("PointsService"):AwardPoints(player.userId, math.random(1,10))
end)

Also, when you see an eror, put the line of the error and put the whole error.

for the second script, Messages inserted in a player doesn't show, the message need to be in Workspace and every players will see it. Try using a Gui to show the message.

Also, the script needs some adjustements so it will be shorter and use local variables

game.Players.PlayerAdded:connect(function(player)
    player.Chatted:connect(function(msg)
        if msg == ":CheckPoints" then
            local a = Instance.new("Message",player) -- 2nd thing is the parent, use local for better results
            a.Text = "There are ".. game:GetService("PointsService"):GetAwardablePoints().." Player Points available"
        elseif msg == ":CheckMyPoints" then
            local a = Instance.new("Message",player)
            local gamebalance = game:GetService("PointsService"):GetGamePointBalance(player.userId)
            local totalpoints = game:GetService("PointsService"):GetPointBalance(player.userId)
            a.Text = "You Earnt "..gamebalance.." Points in this game and a total of "..totalpoints.." Player Points"
        end
    end)
end)
0
I only want it to be visible for the player fahmisack123 385 — 9y
0
Try using a Gui to show the message. tyopido 0 — 9y
Ad

Answer this question