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

Why does this work perfectly w/o FE but it can't get past the first line w/ FE?

Asked by
Viking359 161
6 years ago
Edited 6 years ago

My sword script works fine w/o FE, but with FE on it doesn't even get past the first line. I setup prints along the script and not a single one of the showed in the output. There are no errors either. The main sword function

function onKeyPress(actionName, userInputState, inputObject)
    if userInputState == Enum.UserInputState.Begin then
print("0")
local o = name.."swordout"--name is a variable higher in the script, it's just the player's name
print("1")
local u = name.."swordup"
print("2")
game:WaitForChild("ReplicatedStorage")
print("3")
local f = game.ReplicatedStorage.PlayerAttack
print("4")
local so = f:FindFirstChild(o)
local su = f:FindFirstChild(u)
print("5")
local attacking = true
so:FireServer()
print("6")
    SlashSound:Play()
    wait(.2)
su:FireServer()
print("7")
local attacking = false
    wait(speed)
local ready = true
    else
        wait(0)
    end
    end
 game.ContextActionService:BindAction("keyPress", onKeyPress, false, Enum.KeyCode.Q)

There's a server script triggered by the remote event but it can't even get there so I didn't bother putting it here.

0
The use of whitespace in that code is messier than the American Economy Pejorem 164 — 6y
1
Line 8. Replicated Storage is NOT a Child of game. It is a service. Use game:GetService("ReplicatedStorage") PyccknnXakep 1225 — 6y
0
Also line 25 and 26 are not needed. PyccknnXakep 1225 — 6y

1 answer

Log in to vote
0
Answered by
Pejorem 164
6 years ago

Try using

local contextActionService = game:GetService("ContextActionService")

instead of just using the service outright.

Also consider the fact that this should be in a LocalScript and the LocalScript can only be in certain directories when working under FE. You can find this information out from the page for LocalScript in the API on wiki.roblox.com

0
It is in a local script Viking359 161 — 6y
0
You may also note I mentioned it matters where the local script is Pejorem 164 — 6y
0
It's in a valid location too, but thanks for the getservice part, i forgot about that Viking359 161 — 6y
Ad

Answer this question