Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How would I make a debounce for this script?

pname = script.Parent.Name
player = game.Players:FindFirstChild(pname)
p = script.Parent
Mouse = player:GetMouse()
ls = p.Torso['Left Shoulder']
rs = p.Torso['Right Shoulder']
lh = p.Torso['Left Hip']
rh = p.Torso['Right Hip']
n = p.Torso['Neck']
la = p['Left Arm']
ra = p['Right Arm']
Mouse.KeyDown:connect(function(Key)
	if Key == 'f' then
		p.Torso.Anchored = true
		ls.C0 = ls.C0 *CFrame.Angles(0,-.4,-1.5)
		rs.C0 = rs.C0 *CFrame.Angles(0,.4,1.5)
		sphere = Instance.new('Part', p)
		sphere.CanCollide = false
		sphere.Transparency = .5
		sphere.Shape = 'Ball'
		sphere.Anchored = true
		sphere.BrickColor = BrickColor.new('Really red')
		sphere.Size = Vector3.new(2,2,2)
		sphere.CFrame = p.Torso.CFrame *CFrame.new(0,0,-2)
		wait(5)
		ls.C0 = ls.C0 *CFrame.Angles(-.42,.04,1.5)
		rs.C0 = rs.C0 *CFrame.Angles(-.42,-.04,-1.5)
		p.Torso.Anchored = false
		sphere:remove()
	end
end)

I have tried a few diff times and yet all it would do at that point is it would spam it...

1 answer


--This is much easier than what you were doing
local player = game.Players.LocalPlayer 
local p = player.Character or player.CharacterAdded:wait()
--

Mouse = player:GetMouse()
ls = p.Torso['Left Shoulder']
rs = p.Torso['Right Shoulder']
lh = p.Torso['Left Hip']
rh = p.Torso['Right Hip']
n = p.Torso['Neck']
la = p['Left Arm']
ra = p['Right Arm']

--IMPLEMENTED HERE
deb = false
--

Mouse.KeyDown:connect(function(Key)
    if Key == 'f' and not deb then
    	deb = true
        p.Torso.Anchored = true
        ls.C0 = ls.C0 *CFrame.Angles(0,-.4,-1.5)
        rs.C0 = rs.C0 *CFrame.Angles(0,.4,1.5)
        sphere = Instance.new('Part', p)
        sphere.CanCollide = false
        sphere.Transparency = .5
        sphere.Shape = 'Ball'
        sphere.Anchored = true
        sphere.BrickColor = BrickColor.new('Really red')
        sphere.Size = Vector3.new(2,2,2)
        sphere.CFrame = p.Torso.CFrame *CFrame.new(0,0,-2)
        wait(5)
        ls.C0 = ls.C0 *CFrame.Angles(-.42,.04,1.5)
        rs.C0 = rs.C0 *CFrame.Angles(-.42,-.04,-1.5)
        p.Torso.Anchored = false
        sphere:remove()
        deb = false
    end
end)

Learn more here

This discussion is preserved as it was. New answers, comments, and votes are closed.