This script ain't working and there where no errors:
Code:
local clickDetector = workspace.Button.ClickDetector function onMouseClick() while true do local part = Instance.new("Part", game.Workspace) part.Transparency = 0.5 part.Anchored = false part.Position = Vector3.new(26.17, 52.86, -15.685) end end clickDetector.MouseClick:connect(onMouseClick)
What’s happening is a common case of script exhaustion. Studio only allows scripts to run for a certian amount of time each frame. If that number is exceeded, Studio will end up crashing due to an exhaustion error. The solution is simple, replace while true do
with while wait() do
. Replacing the condition in the while loop with wait()
will wait a duration of one frame every time the while loop runs, allowing the script to run without exhaustion.
You need to add a wait()
. Do it like this:
local clickDetector = workspace.Button.ClickDetector function onMouseClick() while true do local part = Instance.new("Part", game.Workspace) part.Transparency = 0.5 part.Anchored = false part.Position = Vector3.new(26.17, 52.86, -15.685) wait() -- Add this wait end end clickDetector.MouseClick:connect(onMouseClick)
Hope it helped.