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

Brick that Awars player points help?

Asked by 10 years ago

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)
0
I got it from another post biocommand 30 — 10y

1 answer

Log in to vote
0
Answered by 10 years ago

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)

Ad

Answer this question