I'm basically trying to make a simple door opening script that is activated by a gui Button, though the actual script doesn't work and gives an error that says: "Union is not a valid member of Part"
I've tried separating the union and it still wouldn't work. If anyone can help I'd be very happy :)
Script:
local dooropen = workspace.G1.Door.Open.Union local doorclosed = workspace.G1.Door.Closed.Union function Click(mouse) if doorclosed.Transparency == 0 then doorclosed.Transparency = 1 doorclosed.CanCollide = false dooropen.Transparency = 0 dooropen.CanCollide = true else doorclosed.Transparency = 0 doorclosed.CanCollide = true dooropen.Transparency = 1 dooropen.CanCollide = false end end script.Parent.MouseButton1Down:connect(Click)
It errors because in the MouseButton1Down event, it has 2 parameters, those are the X and Y positions of the mouse. And it errors because you used connect not Connect. Wake up. It's deprecated. Here's your code, error free:
By the way, use Button1Click, not Button1Down
-- Assuming this is a LocalScript in a TextButton. script.Parent.MouseButton1Click:Connect(function() -- No passable parameters game:GetService("ReplicatedStorage").DoorOpen:FireServer( game.Workspace.G1.Door.Closed.Union, game.Workspace.G1.Door.Open.Union) end)
Yes it's Fe compatible.
-- Server script. I made it FE compatible just so the entire server sees it. game:GetService("ReplicatedStorage").DoorOpen.OnServerEvent:Connect(function(plr, p, p2) if p.Transparency == 0 then p.Transparency = 1 p.CanCollide = false p2.Transparency = 0 p2.CanCollide = true else p.Transparency = 0 p.CanCollide = true p2.Transparency = 1 p2.CanCollide = false end end)