I tried to make the part (pointPart) turn green when someone collects it and then make it uncollectable while it's green. Everything in the script works, but when the part is green, it will still add a point to leaderstats when someone touches it, I don't want it to.
local pointPart = script.Parent
-- Colors
local blue = Color3.fromRGB(0, 0, 255)
local green = Color3.fromRGB(0,255,0)
-- Services needed
local Players = game:GetService("Players")
local currentColor = pointPart.Color
local canGet = true
local function onTouch(otherPart)
local humanoid = otherPart.Parent:FindFirstChild('Humanoid')
local player = game.Players:FindFirstChild(otherPart.Parent.Name)
if humanoid and player and canGet and currentColor == blue then
canGet = false
player.leaderstats.Gears.Value = player.leaderstats.Gears.Value + 1
print("Giving player gear")
pointPart.Color = green
wait(3)
canGet = true
elseif humanoid and player and canGet and currentColor == green then
print("Player already recieved gear")
end
end
pointPart.Touched:Connect(onTouch)
Thanks

1 comment
Thanks!