I have a check where if a certain key is pressed and the variable enabled is equal to false then things can start happening, but it just goes right through the check. Any ideas what the issue might be?
Web.OnServerEvent:Connect(function(plr, hit, letter)
print(hit)
local LeftHand = plr.Character:WaitForChild("Left Arm")
local RightHand = plr.Character:WaitForChild("Right Arm")
local Enabled = false
if letter == 1 and not Enabled then
Enabled = true
print("This is the left hand and ".. plr.Name.. " pressed Q.")
print(letter)
end
if letter == 2 and not Enabled then
Enabled = true
print("This is the right hand and ".. plr.Name.. " pressed E.")
print(letter)
end
end)
I’m trying to make it so it doesnt pass through the if statement when its not enabled, if I make it false at the end of the if statements then it’ll just keep passing through the ifs.
I like having the two if statements because, I have trouble keeping track of ends and combining it doesn’t work well for my brain, anyway I don’t think that will fix my problem
It doesnt print any errors, it just prints what I have in the if statements.
Like I said it’s just passing through the IF statements when I have it set to enabled
Not related to your problem, but just wanted to tell you that this might run poorly when the game is published. Things will happen too late due to replication. When you press the key from the client, and you send a signal to the server telling it to do stuff, that sending will take some time which is why things happen late. The overhead might not be noticeable in studio.
Do you necessarily need to do this from the server?