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)
I FIGURED OUT THE ANSWER EVERYONE!
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 = character.Head.CFrame + character.Head.CFrame.lookVector*5 + torso.Position end end end end game.ContextActionService:BindAction("keyPress", onKeyPress, false, Enum.KeyCode.R, Enum.KeyCode.E)