I'm trying to make a localscript that when the button is pressed. the switch moves to the other side. But i havent even made it to that point! The "Script.Parent.MouseButton1Click:Connect(function()" Isnt working. Its not even firing. I assume one of the variables is making it wait for eternity or something. Or roblox is lagging. But what am I doing wrong?
-- Services local ReplicatedStorage = game:GetService("ReplicatedStorage") local Players = game:GetService("Players") -- Script Values local Mode = "WonderLand" local CoolDown = false --Objects local BackGround = script.Parent.Parent local Button = script.Parent local Player = Players.LocalPlayer local WonderButton = BackGround.WonderLand local HorridButton = BackGround.HorridLand --Script script.Parent.MouseButton1Click:Connect(function() --Not Working print("Switch Pressed") if not CoolDown and Mode == "WonderLand" then CoolDown = true Mode = "HorridLand" ReplicatedStorage:FindFirstChild("HorridLand").Parent = game.Workspace game.Workspace:FindFirstChild("WonderLand").Parent = ReplicatedStorage Button:TweenPosition(HorridButton.Position) CoolDown = false elseif not CoolDown and Mode == "HorridLand" then CoolDown = true Mode = "WonderLand" ReplicatedStorage:FindFirstChild("WonderLand").Parent = game.Workspace game.Workspace:FindFirstChild("HorridLand").Parent = ReplicatedStorage Button:TweenPosition(WonderButton.Position) CoolDown = false end end)
I highly suggest using
WaitForChild("Ins")
Your object could happen to not load in time, therefore bugs out or something similar.
I fixed it!
-- Services local ReplicatedStorage = game:GetService("ReplicatedStorage") local Players = game:GetService("Players") local Lighting = game:GetService("Lighting") -- Script Values local Mode = "WonderLand" local CoolDown = false --Objects local BackGround = script.Parent.Parent local Button = script.Parent local Player = Players.LocalPlayer local Safe = Player:FindFirstChild("Safe") local WonderButton = BackGround.WonderLand local HorridButton = BackGround.HorridLand --Script script.Parent.MouseButton1Click:Connect(function() print("Switch Pressed") if CoolDown == false and Mode == "WonderLand" then --MAKES IT DARKER AND GOTH CoolDown = true Mode = "HorridLand" Button:TweenPosition(HorridButton.Position, nil, nil, 0.7) wait(0.7) ReplicatedStorage:FindFirstChild("HorridLand").Parent = game.Workspace game.Workspace:FindFirstChild("WonderLand").Parent = ReplicatedStorage Lighting.ClockTime = 1 wait(0.4) CoolDown = false elseif CoolDown == false and Mode == "HorridLand" then -- MAKES IT LESS GOTH CoolDown = true Mode = "WonderLand" Button:TweenPosition(WonderButton.Position, nil, nil, 3.4) wait(3.4) ReplicatedStorage:FindFirstChild("WonderLand").Parent = game.Workspace game.Workspace:FindFirstChild("HorridLand").Parent = ReplicatedStorage Lighting.ClockTime = 14 wait(0.6) CoolDown = false end end)
Heh.. My error was i was trying to use TweenService for a gui...