So, I made a script so that when you press the Q key, you sit down. How do you make a script to stand up by pressing the button again?
this is the script:
local plr = game.Players.LocalPlayer
local uis = game:GetService("UserInputService")
uis.InputBegan:Connect(function(key,_)
if key.KeyCode == Enum.KeyCode.Q then
if plr.Character ~= nil then
plr.Character.Humanoid.Sit = true
end
end
end)
if plr.Character.Humanoid.Sit = true then --this is the standing up part i tried adding.
uis.InputBegan:Connect(function(key,_)
if key.KeyCode == Enum.KeyCode.Q then
if plr.Character ~= nil then
plr.Character.Humanoid.Sit = false
end
end
end)
The only solution i could find is make the stand up part use a different key. also, i get this error when i test the script: Expected 'then' when parsing if statement, got '='

3 comments
You forgot to add an end to the "if" statement in line 12
And you also wrote "if Character.Humanoid.Sit = true then" it's supposed to be ==
the script works, but my character still doesn't stand up. Thanks for the help, though