I have a script to fire a RemoteEvent which makes the part gradually disappear for the local player, however the transparency on here is jittering.
Video (potential epilepsy warning)
Here’s my script that makes it disappear:
function variables(name, part, functionName, sendscript)
if functionName == "disappear" then
for t = 0, 1, 0.05 do
part.Transparency = t
wait()
end
part.CanCollide = false
wait(5)
part.CanCollide = true
part.Transparency = 0
end
end
game.ReplicatedStorage.BrickProperties.OnClientEvent:Connect(variables)
In the serverscript, I’m using a .Touched event to fire the client.
This is server-sided correct? Debounce is only used so a piece of code can’t be executed super fast. It shouldn’t mess up any view of the parts transparency for users.
Edit: I see you are firing to the client, why not make it full server?
If one person touches it, they have a time limit to make it to the other side before it disappears entirely, which could mess up other players if, say, one person is just standing on it and having it repeatedly disappear.
what it sounds like is you should make this all client-sided (you only need one localScript). Try this:
local part = workspace.lolPart
local debounce = true
part.Touched:Connect(function(touchingPart)
local touchingPlayer = game:GetService("Players"):GetPlayerFromCharacter(touchingPart.Parent)
if debounce == true and touchingPlayer and touchingPlayer == game:GetService("Players").LocalPlayer then
debounce = false
for t = 0, 1, 0.05 do
part.Transparency = t
game:GetService("RunService").Heartbeat:Wait()
end
part.CanCollide = false
wait(5)
debounce = true
part.CanCollide = true
part.Transparency = 0
end
end)
That would work, the downside being having to make an individual name for each part, however since there are stages, it probably could work relatively easily with prefixes and suffixes.
actually, you can make it for many parts. Try this:
local folderContainingParts = workspace.lolFolder
local debounce = true
for _, v in pairs(folderContainingParts:GetChildren()) do
v.Touched:Connect(function(touchingPart)
local touchingPlayer = game:GetService("Players"):GetPlayerFromCharacter(touchingPart.Parent)
if debounce == true and touchingPlayer and touchingPlayer == game:GetService("Players").LocalPlayer then
debounce = false
for t = 0, 1, 0.05 do
v.Transparency = t
game:GetService("RunService").Heartbeat:Wait()
end
v.CanCollide = false
wait(5)
debounce = true
v.CanCollide = true
v.Transparency = 0
end
end)
end
also, heartbeat is an event that only the client can listen for. It fires approximately every frame. It is really useful for effects such as changing the transparency here.