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

Script with local variables visible on server?

Asked by 5 years ago

Hi everyone,

This Touched part color changing script with local variables is having a few problems I can't seem to solve (placed within the Checkpoint 2 part).

local brick = game.Workspace["Checkpoint 2"]
script.Parent.Touched:connect(function (hit)    
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if player then
brick.Color = Color3.fromRGB(255,9,243) --Random color for testing purposes
brick.Material= Enum.Material.Neon
end
end)

The first issue, which is the biggest one, is that the script fires server wide (the whole server can see the changed color). This code should only be visible to the client but when I test it publically, all my test characters see the changed effect. How can I fix this? The other issue is that it takes a while for the material to change from SmoothPlastic to Neon (at least 5 seconds) when I want it to change as instantly as the color change. Is there a way to reduce the amount of time it takes to change materials?

Thanks in advance,

ObeseKing

0
Make sure this is in a local script. Judging by the fact that `script.Parent` is a part, I'd assume it's a server script. RayCurse 1518 — 5y

Answer this question