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

Why won't these functions execute?

Asked by 7 years ago

I was making a script, but when I say to execute a function when a certain key is pressed, nothing happens. Also - don't say I should switch to RemoteEvents instead of KeyDown, because RemoteEvents are just awful... Here is the script:

001wait(0.1)
002 
003local player = game.Players.LocalPlayer
004local char = player.Character
005local mouse = player:GetMouse()
006 
007local s1 = false
008local s2 = false
009 
010ssj = false
011 
012function ssj()
013    char.Torso.Anchored = true
014    if ssj == false then ssj = true print("SSJ was false.") end
015    delay(0, function()
View all 201 lines...
0
Firstly, can you be more specific with where your error is, and where you called the function? A 201-line script is quite large, so could you please make it easier for us to solve? Also, although you aren't in favour of it, RemoteEvents are mandatory if you are using a LocalScript to create instances, due to FilteringEnabled. Furthermore, KeyDown is deprecated, so avoid using it. UgOsMiLy 1074 — 7y
0
I think I know where the problem is. "ssj" is the name of both a function and a variable, so it would confuse the script, and it doesn't know whether you are talking about the boolean or the function, so it assumes one, preferably the one that you don't want. Change "ssj" (the true/false value) to something else. UgOsMiLy 1074 — 7y
0
The problem is lines 194 & 197: Whenever the player hits the 'h' key, it'll always go to the first conditional statement; you'll have to set up your script to detect whether SSJ is on or off. TheeDeathCaster 2368 — 7y

Answer this question