Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

The code isn't running inside of the function when it's activated?

local debounce = true
game:GetService("ReplicatedStorage").FadeTouched.OnServerEvent:Connect(function(plr,v)
            if debounce then
                debounce = false
            while v.Transparency <= 1 do 
                v.Transparency = v.Transparency + 0.01
                wait(0.01)
            end
            v.CanCollide = false
            wait(3)
            v.CanCollide = true
            v.Transparency = 0
            debounce = true
            end
end)

This is the server event function, it doesn't run the code in the function.

script.Parent.Touched:Connect(function(hit)
	local player = game.Players:GetPlayerFromCharacter(hit.Parent)
	if player then
	game.ReplicatedStorage.FadeTouched:FireClient(player,script.Parent)
	end
end)

This is the part that activates the event only to the client, so it fades locally.

4 comments

0

so the top code is a LocalScript?

0

No, its a serverscript

0

So I'm kind of confused... What are you actually trying to accomplish?

0

I'm trying to make the brick fade locally using fireclient() function

1 answer

✓ Accepted answer

I am still not entirely sure what you're trying to accomplish... so if you want the brick to disappear locally then you need to put the top part into a LocalScript and use OnClientEvent instead of OnServerEvent

--Client Script (LocalScript)

local debounce = true
game:GetService("ReplicatedStorage").FadeTouched.OnClientEvent:Connect(function(v)
            if debounce then
                debounce = false
            while v.Transparency <= 1 do 
                v.Transparency = v.Transparency + 0.01
                wait(0.01)
            end
            v.CanCollide = false
            wait(3)
            v.CanCollide = true
            v.Transparency = 0
            debounce = true
            end
end)

and for the server script

--Server Script (Script)

script.Parent.Touched:Connect(function(hit)
    local player = game.Players:GetPlayerFromCharacter(hit.Parent)
    if player then
    game.ReplicatedStorage.FadeTouched:FireClient(player,script.Parent)
    end
end)

as I said I still don't know what you're trying to accomplish, so if I'm wrong you could elaborate on that

1 comment

0

Ohhh

This discussion is preserved as it was. New answers, comments, and votes are closed.