Hi, I was trying to make a grid placement script and I made this script to run the placement:
UserInputService.InputChanged:connect(function(inputObj) if (inputObj.UserInputType == Enum.UserInputType.MouseMovement) then if build.Value == true then Movement() UserInputService.InputEnded:Connect(function(input) if input.UserInputType == Enum.UserInputType.MouseButton1 then local copy = Model:Clone() copy.Parent = Model.Parent copy:SetPrimaryPartCFrame(CFrame.new(PosX, PosY, PosZ)) end end) end end end)
Movement script :
local function Movement() Mouse.TargetFilter = Model --Ignores the model Snap() -- Gets the variables ready (We will snap later) Model:SetPrimaryPartCFrame(CFrame.new(PosX, PosY , PosZ)) -- Moves the model end
But using this script causes it to lag the game and even crash roblox studio. It outputs this error : 15:26:07.994 - RunService:fireRenderStepEarlyFunctions unexpected error while invoking callback: Players.awesomecaysson.PlayerScripts.PlayerModule.CameraModule.ZoomController.Popper:248: Script timeout: exhausted allowed execution time
Using a while true do script didn't work (with wait()). Is there a way to decrease the chance of getting an error?
Answer found! I took out UserInputService.InputEnded:Connect(function(input) (like SteelMettle1 said) and just changed it with Mouse.Button1Down:Connect(function())