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

Brick that Awars player points help?

Hello there I have a doubt scripting this, how do I make this? when you touch a brick you recieve a player point, now I have this script, but I am not sure if its correct

local egg = script.Parent
egg.Touched:connect(function(part)
local g = game.Players:GetPlayerFromCharacter(part.Parent)
if part:IsA("Part") and (g) then
local f = g:findFirstChild("leaderstats")
local n = f:FindFirstChild("Points")
n.Value = n.Value + 1
egg:remove()
end
end)

1 comment

0

I got it from another post

1 answer

That script has nothing to do with Player Points. Therefore, I will transform your script to work with player points. Note the game will need some stored.

local egg = script.Parent
egg.Touched:connect(function(part)
local g = game.Players:GetPlayerFromCharacter(part.Parent)
if part:IsA("Part") and (g) then
pps = game:GetService("PointsService")
if pps:GetAwardablePoints() >= 1 then
	pps:AwardPoints(g.userId, 1)
end
egg:remove()
end
end)

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