I want something to happen when I press the Q key and I want something else to happen when I press it again
LOCAL
local TWS = game:GetService("TweenService") local input = game:GetService("UserInputService") input.InputBegan:Connect(function(io, key) if io.KeyCode == Enum.KeyCode.Q then script.RemoteEvent:FireServer() script.Disabled = true end end)
GLOBAL
local Event = script.Parent local db = true local Carpeta = script.Parent.Parent.FX local User = game:GetService("UserInputService") local Agarre = Instance.new("Weld") local Hab = Carpeta:Clone() Event.OnServerEvent:Connect(function(plr) local Torso = plr.Character.HumanoidRootPart Hab.Parent = workspace local Stand = Hab.Stando Agarre.Parent = Torso Agarre.Part0 = Torso Agarre.Part1 = Stand.HumanoidRootPart Agarre.C1 = CFrame.new(-3,-1.5,-2) end)
You could add a dictionary on the server in terms to check if it's already been pressed before or not.
local Dictionary = {} local Players = game:GetService('Players') Event.OnServerEvent:Connect(function(Player) if Dictionary[Player.Name] == true then Dictionary[Player.Name] = false local Torso = plr.Character.HumanoidRootPart Hab.Parent = workspace local Stand = Hab.Stando Agarre.Parent = Torso Agarre.Part0 = Torso Agarre.Part1 = Stand.HumanoidRootPart Agarre.C1 = CFrame.new(-3,-1.5,-2) elseif Dictionary[Player.Name] == false then Dictionary[Player.Name] = true -- do other stuff end -- dictionary check end) -- onEvent Players.PlayerAdded:Connect(function(Player) if not Dictionary[Player.Name] then Dictionary[Player.Name] = false end -- dictionary check end) Players.PlayerRemoving:Connect(function(Player) if Dictionary[Player.Name] then Dictionary[Player.Name] = nil end -- dictionary check end) -- onRemoving