I made this Script, and when I realized it had to be a LocalScript and I moved it to a LocalScript, it stopped working. As a Script, it works the way I want it to, but when in a LocalScript, it doesn't even run the script (It didn't even print()
something I told it to print in the first line of my script, and the rest doesn't get run either.) Both scripts were in Workspace when I tested them. The script is here:
print("deb") --My attemp at debugging wait(3) local player = game.Players.LocalPlayer local RunService = game:GetService('RunService') local ContextActionService = game:GetService('ContextActionService') local eActivated = false local bombReload = tick() local currentBomb = nil local playerTorsoPos = player.Character.LowerTorso.Position function round(num) if num >= 0 then return math.floor(num+.5) else return math.ceil(num-.5) end end function roundTo5(num) --These snap the object to a grid num = round(num) num = num / 5 num = round(num) num = num * 5 return num end local function makeBomb() --Creates the object when E is pressed currentBomb = Instance.new("Part", Workspace) currentBomb.Name = player.Name currentBomb.Shape = "Ball" currentBomb.Anchored = true currentBomb.CanCollide = false currentBomb.Size = Vector3.new(4, 4, 4) currentBomb.Material = "Metal" currentBomb.BrickColor = BrickColor.new("Dark blue") currentBomb.CFrame = CFrame.new(roundTo5(playerTorsoPos.X), 3, roundTo5(playerTorsoPos.Z)) wait(3) end local function onE(actionName, inputState) --Finds out when E is pressed if inputState == Enum.UserInputState.Begin then eActivated = true elseif inputState == Enum.UserInputState.End then eActivated = false end end local function onUpdate() --Calls funcion to create object print("deb") --Debug for if this loop is running if player.Character and player.Character:FindFirstChild('Humanoid') then if eActivated and (tick() - bombReload) > 1 then print("You just pressed E") --Debug if it gets the signal that E was presssed --print(tick()-bombReload) bombReload = tick() makeBomb() end end end RunService:BindToRenderStep('Control', Enum.RenderPriority.Input.Value, onUpdate) ContextActionService:BindAction('Jump', onE, true, 'e', Enum.KeyCode.DPadUp, Enum.KeyCode.ButtonA)
So, my problem was, that I had the LocalScript in the Workspace. After moving it to StarterPlayerScripts, it started working.