local cam = game.Workspace.CurrentCamera
local remote = game.ReplicatedStorage.Events.setvalue
local remote2 = game.ReplicatedStorage.Events.setvalue2
script.Parent.Parent.Parent.BottomButton.MouseButton1Click:connect(function()
local clicked = false
local LoadChar = game.ReplicatedStorage.Events:WaitForChild("LoadChar")
local player = game.Players.LocalPlayer
local Pos = player.Character:GetPrimaryPartCFrame()
local currentCamera = workspace.CurrentCamera
if clicked == false then
clicked = true
remote:FireServer(player)
end
if clicked == true then
clicked = false
LoadChar:FireServer()
cam.CameraSubject = player.Character.Humanoid
cam.CameraType = "Custom"
cam.CFrame = player.Character.Head.CFrame
end
end)
For some reason, when i click the button, it respawns my player, even though it says if clicked == false then
it literally isnt working, and i have no idea why. The value is set to false. Not true… what do i do?
its because the script reads from top to down so it fires the if clicked == false then AND because you set condition to true in it the next if is also true.
EDIT: some showcase
local clicked = false
if clicked == false then -- 1:check if false and it is
clicked = true -- 2:changes it to true
remote:FireServer(player)
end
if clicked == true then -- 3:checks if true and because of 2 it is now true and fires
clicked = false -- 4:sets it back to false
Alright, its a different story now, if its R6, and you want to save it too for next reloading, I’d recommend using HumanoidDescription or an array containing items such as hats and shirts.
You need to check the if statements and see if everything works properly, dont forget to use else/elseif when needed, it can help alot.
for some reason. even with all the content commented out. it still fires the clicked == false remote when i click it twice, its like the variable never changes. and i have no idea why
local cam = game.Workspace.CurrentCamera
local remote = game.ReplicatedStorage.Events.setvalue
local remote2 = game.ReplicatedStorage.Events.setvalue2
local clicked = false
--local LoadChar = game.ReplicatedStorage.Events:WaitForChild("LoadChar")
local player = game.Players.LocalPlayer
local currentCamera = workspace.CurrentCamera
local name = player.Name
script.Parent.Parent.Parent.BottomButton.MouseButton1Click:connect(function()
--local Pos = player.Character:GetPrimaryPartCFrame()
if clicked == false then
remote:FireServer(player)
clicked = true
end
if clicked == true then
-- LoadChar:FireServer()
--player.Character:SetPrimaryPartCFrame(Pos)
--remote2:FireServer(player.Character)
--LoadChar:FireServer()
--cam.CameraSubject = player.Character.Humanoid
--cam.CameraType = "Custom"
--cam.CFrame = player.Character.Head.CFrame
clicked = false
end
end)
Make another value( can be boolean,number etc…) and name it “Debounce”. Now, everytime you pressed the button, you should change the debounce value, wait a couple of secs, and turn it back. Not on pc currently, and its actually 3 AM for me, so I cant do much. But, I think you better use remoteFunction( u can return with it, and re- use it)