Hi, I made a script so that when a player clicks Z a part is supposed to summon infront of them... but for some reason the part summons only in the middle of the game, and nowhere else. Please help me!
local player = game.Players.LocalPlayer
local character = player.CharacterAdded:wait()
local humanoid = character.Humanoid
local torso = character.UpperTorso
local God = player.PlayerGui.ChooseCharacter.God
--BREAKLINE--
function onKeyPress(actionName, userInputState, inputObject)
if userInputState == Enum.UserInputState.Begin then
if inputObject.KeyCode.Name ==("E") then
if God.Value ==("Zeus") then
print("THUNDERBOLT!")
local Thunder = Instance.new("Part",workspace)
Thunder.CFrame = torso.CFrame + torso.CFrame.lookVector*-5 + torso.Position --I think the error is here!--
end
end
end
end
game.ContextActionService:BindAction("keyPress", onKeyPress, false,
Enum.KeyCode.R,
Enum.KeyCode.E)

4 comments
Is this a localscript or a serverscript?(Serverscript is Normal Script)
oh I figured out the answer, thx anyway
Too bad, later on you will figure out that it is only visible for you.
wait what do you mean? But if it was in a ServerScript, then I cant use keys...