Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

can you put a if in a if statement and help with checking if player has pressed e?

Asked by 4 years ago
Edited 4 years ago

in my game i am trying to make if a player is on one part then if they press a key a function will be triggered after multiple testing i have not succeeded, so i have two questions can you put a if inside a if statement (this is the way i have been trying to use) and if yes/no how can i fix it

this is the code i have been using i removed the if statement inside the if statement i was using because i thought it wasn't necessary if you want it please ask.

debounce = false

script.Parent.Touched:connect(function(hit)

01if not debounce then
02 
03        debounce = true
04        if(hit.Parent:FindFirstChild("Humanoid")~=nil)then
05 
06 
07 
08 
09        local player = game.Players:GetPlayerFromCharacter(hit.Parent)
10        local sound = script.Parent.Sound:Clone()
11        sound.Parent = player.PlayerGui
12        sound:Play()
13        wait(5)
14        local player = game.Players.LocalPlayer
15        local mouse = player:GetMouse()
View all 27 lines...

end)

0
yes, you can nest your if statements. You can also try complex conditionals (and/or). Also, please re-enter your code, there is no if-statements provided and its not yet formatted. YTRaulByte 389 — 4y
0
i tried simplifying it and i realize now that is i code a tried but decided not to use here is the one i'm trying to get to work  yoursoulsaver 5 — 4y
0
i put it in the edit yoursoulsaver 5 — 4y

2 answers

Log in to vote
0
Answered by 4 years ago

Yes, you can add an if statement inside one. I'll give you a quick example:

1if 2+2==4 then
2    if 1+1==2 then
3        print("all was correct")
4    end
5end
0
Cool thank you yoursoulsaver 5 — 4y
Ad
Log in to vote
0
Answered by 4 years ago

https://www.google.com/url?sa=t&source=web&rct=j&url=https://www.youtube.com/watch%3Fv%3DvujSeb6X2bE&ved=2ahUKEwiIsc2ZvL_qAhUQX30KHTfPD1EQwqsBMAF6BAgLEAg&usg=AOvVaw00Sd2wEo4HBy53-R3w5dMo

Roblox | Hotkey / Key Pressed Event | Scripting Tutorial ( video link above )

https://www.google.com/url?sa=t&source=web&rct=j&url=https://www.youtube.com/watch%3Fv%3DvujSeb6X2bE&ved=2ahUKEwiIsc2ZvL_qAhUQX30KHTfPD1EQwqsBMAF6BAgLEAg&usg=AOvVaw00Sd2wEo4HBy53-R3w5dMo

Key Press Detection (Press E) - UserInputService - Advanced Roblox Scripting #2

0
this kinda helps thanks yoursoulsaver 5 — 4y
0
why downvote? Newh0hrizonCz 58 — 4y

Answer this question