I’m trying to make it so when I click a button, a part changes its transparency to 0, and when I click it again, it goes back to 1.
I’ve only managed to make it go to 0 but I can’t find a way to make it go back up to 1 once I press it again.
I have Filtering Enabled so I made a Remote Event script and one in StarterGui
LocalScript in StarterGui:
local clickdetector = game.Workspace.Part.ClickDetector
clickdetector.MouseClick:Connect(function()
game.Workspace.RemoteEvent:FireServer()
end)
I was under the impression that ClickDetectors aren’t subject to FilteringEnabled - at least if a client activates a click detector, it will fire MouseClick on the server.
Why use local script? I think this is just making it a problem. Just put a normal script and the ClickDetector inside that part, you’ll need no Remote Events.
Aight, i done something, i used FireAllClients(), is that ok? But it seems to have worked:
--Put the event "ChangeBrickTransparency" in Replicated Storage.
--Name the event "ChangeBrickTransparency", "CBT"
--ServerScript in ServerScriptService.
game.Workspace.Part.ClickDetector.MouseClick:Connect(function()
game.ReplicatedStorage:WaitForChild("CBT"):FireAllClients()
end)
--LocalScript, in StarterPlayerScripts.
local Part = game.Workspace.Part
local CBT = game.ReplicatedStorage:WaitForChild("CBT")
CBT.OnClientEvent:Connect(function()
if Part.Transparency == 1 then
Part.Transparency = 0
elseif Part.Transparency == 0 then
Part.Transparency = 1
end
end)
Tell me if it works, at least for me it works fine.
Wasn’t that what the event is called? Nevermind, i guess the “ChangeBrickTransparency” doesn’t exist, instead of that, just name the Remote Event you used earlier, then do what i told you.
Hello? Newer Roblox games now are FilteringEnabled, and I’m pretty sure the one I made few days ago are FilteringEnabled and using ClickDetector without local script is fine.