Hey! I have this script that executes a sequences of actions once you click on the part, the issue is I want it to happen locally for each player, meaning the code will execute for a player that clicks it, but for other players around them, nothing happens until they also click it.
I’ve tried running it as a localscript, but I assume it cant call certain things that the normal script could.
local smoke = part:FindFirstChildOfClass("Smoke")
local sound = part:FindFirstChildOfClass("Sound")
local decal = part:FindFirstChildOfClass("Decal")
local function onClicked()
if sound then
sound:Play()
end
if smoke then
smoke.Enabled = true
end
if decal then
decal:Destroy()
end
wait(1.5)
if smoke then
smoke.Enabled = false
end
part.CanCollide = false
end
if part:FindFirstChildOfClass("ClickDetector") then
part.ClickDetector.MouseClick:Connect(onClicked)
end
that’s only in the case of indexing serverside things like… SSS AKA ServerScriptService and SS AKA ServerStorage local scripts cannot Index these areas*
Edit: also your local script will not run outside a character
LocalScripts can’t run inside Workspace so you should have it preferably inside StarterPlayerScripts where you’d reference the ClickDetector in the script.
Thank you! I moved the code to a LocalScript in StarterPlayerScripts, but its still disappearing for everyone in the server. Any clue on how to actually get it working locally?
local guy = nil
repeat
guy = game.Workspace.littleThingsGuys:FindFirstChild("glumpy")
wait(0.1)
until guy
print('found guy')
local smoke = guy:FindFirstChild("Smoke")
print('found smoke')
local sound = guy:FindFirstChild("Sound")
print('found sound')
local decal = guy:FindFirstChild("Decal")
print('found decal')
local function onClicked()
if sound then
sound:Play()
end
if smoke then
smoke.Enabled = true
end
if decal then
decal:Destroy()
end
wait(1.5)
if smoke then
smoke.Enabled = false
end
guy.CanCollide = false
end
if guy:FindFirstChildOfClass("ClickDetector") then
guy.ClickDetector.MouseClick:Connect(onClicked)
end
local guy = nil
repeat
guy = game.Workspace.littleThingsGuys:FindFirstChild("glumpy")
wait(0.1)
until guy
print('found guy')
local smoke = guy:FindFirstChild("Smoke")
print('found smoke')
local sound = guy:FindFirstChild("Sound")
print('found sound')
local decal = guy:FindFirstChild("Decal")
print('found decal')
local function onClicked(player)
if player ~= game.Players.LocalPlayer then return end -- the local player didn't click this, so ignore it
if sound then
sound:Play()
end
if smoke then
smoke.Enabled = true
end
if decal then
decal:Destroy()
end
wait(1.5)
if smoke then
smoke.Enabled = false
end
guy.CanCollide = false
end
if guy:FindFirstChildOfClass("ClickDetector") then
guy.ClickDetector.MouseClick:Connect(onClicked)
end
Try checking if the person who clicked the ClickDetector is the local player?