This script makes a part's (pointPart's) color change from blue to green, makes 2 models transparent, adds one point to the leaderboard when someone touches pointPart, and makes it so nobody can get a leaderstat point by touching pointPart again. I want to make the color change and the transparency change locally, not globally, and I want to make it so that only the person who touches pointPart cannot get a leaderstat point by touching it again, but everyone else can. Making the script a local script doesn't work, how do I do this?
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 canGet = true
local function onTouch(otherPart)
local humanoid = otherPart.Parent:FindFirstChild('Humanoid')
local player = game.Players:FindFirstChild(otherPart.Parent.Name)
local currentColor = pointPart.Color
local model = script.Parent.Parent.Gear
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
for i, block in model:GetChildren() do
if block:IsA("Part") or ("UnionOperation") then
block.Transparency = 0.5
elseif humanoid and player and canGet and currentColor == green then
print("Player already recieved gear")
end
end
end
end
local function onTouch2(otherPart)
local humanoid = otherPart.Parent:FindFirstChild('Humanoid')
local player = game.Players:FindFirstChild(otherPart.Parent.Name)
local currentColor = pointPart.Color
local model = game.Workspace.Fakegear
if humanoid and player and canGet and currentColor == blue then
wait(5)
for i, block in model:GetChildren() do
if block:IsA("Part") or ("UnionOperation") then
block.Transparency = 0.5
canGet = true
end
end
end
end
pointPart.Touched:Connect(onTouch)
pointPart.Touched:Connect(onTouch2)

1 comment
Maybe if its a localscript make the player val local player = game.Players.LocalPlayer