Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to make this function stop working after 10 seconds?

Asked by
sonuka 24
6 years ago

How do I make it disconnect?

local player = game.Players.LocalPlayer
local hr = Player.Character.HumanoidRootPart 
local mouse = player:GetMouse()

mouse.Move:connect(function()
    hr.CFrame = CFrame.new(hr.Position, mouse.Hit.p*Vector3.new(1,0,1) + hr.Position*Vector3.new(0, 1, 0))
wait(10)
--What do I do to make it disconnect?
end)
0
`con = mouse.Move... wait(10) con:Disconnect()`? TheeDeathCaster 2368 — 6y
0
script:Destroy() maybe? or script.Disabled = true noammao 294 — 6y
0
I already tried disconnect won't work sonuka 24 — 6y

1 answer

Log in to vote
-1
Answered by
Kblow1 53
6 years ago
Edited 6 years ago

Try this

local player = game.Players.LocalPlayer
local hr = Player.Character.HumanoidRootPart 
local mouse = player:GetMouse()

mouse.Move:connect(function()
    hr.CFrame = CFrame.new(hr.Position, mouse.Hit.p*Vector3.new(1,0,1) + hr.Position*Vector3.new(0, 1, 0))
wait(10)
break
end)
0
You capitalized break theCJarmy7 1293 — 6y
0
Also, break doesn't work in functions, only in loops. theCJarmy7 1293 — 6y
0
Ya ;/ sonuka 24 — 6y
0
Yea sorry about that... I didn’t realize. I figured it would work but didn’t relieve at the moment break can’t be used in functions Kblow1 53 — 6y
Ad

Answer this question