I have an event that is fired upon the player clicking a button. The event fires and the server gets information on what to do, but for some reason this if statement doesn’t run. I even ran a print function to see what the value was and it printed “Elevator AZ”, and the if statement requires it to be “Elevator AZ”, which it is, but the if statement doesn’t run and nothing from it prints… No errors. No misspelling.
print(interactionType)
----------------------
elseif interactionType == "Elevator AZ" then
> Output: Elevator AZ
M’kay, but it will still be very short due to how long the script is. (700+ lines for the event)
game.ReplicatedStorage.ClientRemotes.Interact.OnServerEvent:Connect(function(player, interactedWith, interactionType)
print(interactionType) -- "prints Elevator AZ"
if interactionType == "Door" then
elseif tostring(interactionType) == "Elevator AZ" then
print("o") -- not printed, but interactionType is equal to Elevator AZ, meaning the if statement thinks that interactionType is not equal to Elevator AZ even though the print above shows in the output that interactionType is equal to Elevator AZ??
end
end)
-- rest of the code wont be shown due to how long it is
well, what are those two variables being sent over?
I just did a very simple test, and fired the event with a random workspace part for the interactedWith, and a string “Elevator AZ” and it worked like normal.
Is there by any chance another “if” or “elseif” that the code might be going to before it reaches the “Elevator AZ” one? You could put random print statements in the conditional to see where the code is being routed.
player is quite obvious. interactedWith is just the parent of the “InteractionPart”, but just don’t mind that. interactionType is the type of interaction, like “Door”, “Button”, or “Elevator AZ” which is an elevator for a specific area.