I have a folder called “Dissapearing” where I put all the blocks that I want to dissapear when they are touched. See code below:
for i,v in pairs(game.Workspace.Dissapearing:GetChildren()) do
if v:IsA("Part") then
local db = false
v.Touched:Connect(function()
coroutine.wrap(function()
if db == false then
db = true
for i = 1, 20 do
v.Transparency = i/20
wait(0.05)
end
v.CanCollide = false
wait(2)
v.CanCollide = true
v.Transparency = 0
db = false
end
end)()
end)
end
end
This code is in a local script in startercharacter scripts. I have also put it in startergui before, and although the blocks are dissapearing, they are doing it to the whole server, meaning other players also can see the dissapearing parts.
I do not know what to do… this is in a localscript and its working on the server…
Hey, although I’m not 100% sure, I think this issue may be happening because you aren’t checking the player who touched. Simply add a check to see if the game.Players:FindFirstChild(hit.Parent.Name) == LocalPlayer, then remove the part.
Make Sure script is only running on client, i tested it and it’s working
Server:
Client:
Maybe you could have at the same time a script that run on server and one on client
Also Tip: Put it on StarterPlayerScripts it’s more correct.
Alright, had time to test my hypothesis here and I can confirm that your issue here is my original theory.
To clarify here, it isn’t actually disappearing on the server, it will stay on the server regardless. However, you can think of this kind of like doing :FireAllClients from a ServerScript. Because every single client is listening to anything that touches the part whatsoever, whenever any client touches that part, that part will dissapear for every client. The following will stop that from happening:
for i,v in pairs(game.Workspace.Dissapearing:GetChildren()) do
if v:IsA("Part") then
local db = false
v.Touched:Connect(function(hit)
if game.Players:FindFirstChild(hit.Parent.Name) then
local plr = game.Players:FindFirstChild(hit.Parent.Name)
if plr == game.Players.LocalPlayer then
coroutine.wrap(function()
if db == false then
db = true
for i = 1, 20 do
v.Transparency = i/20
wait(0.05)
end
v.CanCollide = false
wait(2)
v.CanCollide = true
v.Transparency = 0
db = false
end
end)()
end
end
end)
end
end
Perfect! I didnt think of this. thanks so much
1 Like