Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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.

3 comments

0

The use of whitespace in that code is messier than the American Economy

1

Line 8. Replicated Storage is NOT a Child of game. It is a service. Use game:GetService("ReplicatedStorage")

0

Also line 25 and 26 are not needed.

1 answer

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

3 comments

0

It is in a local script

0

You may also note I mentioned it matters where the local script is

0

It's in a valid location too, but thanks for the getservice part, i forgot about that

This discussion is preserved as it was. New answers, comments, and votes are closed.