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

How do I remove the player's force field? [ANSWERED]

How do I remove the player's force field without breaking when the player doesn't have a force field?

local animation = Instance.new('Animation')
local animTrack
local debounce = false
local player = game.Players.LocalPlayer.Character

function onEquip()
   script.Parent.Handle.UnsheathSound:Play()
end

function onActivate()
    if not debounce then
	debounce = true
	player.ForceField:Destroy()
	animation.AnimationId = "http://www.roblox.com/asset/?id=129967390"
	animTrack = player.Humanoid:LoadAnimation(animation)
	animTrack:Play()
	script.Parent.Handle.SlashSound:Play()
	script.Parent.Handle.Script.Disabled = false
	wait(0.5)
	animTrack:Stop()
	script.Parent.Handle.Script.Disabled = true
	wait(0.5)
	debounce = false
    end
end

function onUnequip()
    animTrack:Stop()
end

script.Parent.Equipped:connect(onEquip)
script.Parent.Unequipped:connect(onUnequip)
script.Parent.Activated:connect(onActivate)

3 comments

0

Just check if he has a forcefield before you go and try to remove one. Do if player:FindFirstChild('ForceField') then player.ForceField:Destroy() end

0

Thanks it works!

0

you don't need a script to do that

1 answer

Even though you already got your answer, a WAY easier way you could disable the Force Field without using scripts is to go to the SpawnLocation Properties and change the Force Field Duration to 0

2 comments

0

Assuming you are using a spawn location Part

0

Real useful man

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