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)

7 comments
Might be because it's a local script. Try it in a normal script, remove the Player variable, and instead of "script.Parent.MouseButton1Click:Connect(function()", do "script.Parent.MouseButton1Click:Connect(function(Player)". This gets the Local player.
Oh! I might be wrong here, where it says "if not CoolDown", try "if not CoolDown == true and Mode == WonderLand then".. Sorry if I'm wrong here, I'm a bit new with scripting
correction: do "if not Cooldown == true" on all of the ones that reference it.
Nothing has worked. By the way! I know your new so i'll correct you. I dont believe you can edit a gui in a normal script
Why would you allocate 'Button', then neglect it with referencing 'script.Parent' directly? ':FindFirstChild()' is not a replacement for the dot operator, you should not be using it in this program.
It can't just "not work". What is the program type, location, and Instance classification of the Button.
No worries! I fixed it. I will post how i fixed it later!