Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Why won't this work?? [SOLVED]

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)

2 comments

0

Message script: Try making it into local script and make "a" Parent game.Workspace.CurrentCamera (LocalPlayer's camera)

0

Can't. Player Points

1 answer

✓ Accepted answer
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)

2 comments

0

I only want it to be visible for the player

0

Try using a Gui to show the message.

This discussion is preserved as it was. New answers, comments, and votes are closed.