Remove Forcefield when walking

I have this script

Humanoid.Running:Connect(function(speed)
    if speed > 0.01 then
        Character.ForceField:Destroy()
    end
end)

I put it in a server script in server script service but it doesn’t seem to work

1 Like

Any errors in the output? I believe this is not the full script, Humanoid and Character is not mentioned in the code you have provided. If possible, could you show your full code?

Theres one error its at

Humanoid.Running:Connect(function(speed)

and thats the whole script

What is the error message? Share a screenshot or just copy the error message

ServerScriptService.Script:1: attempt to index nil with ‘Running’ - Server - Script:1

1 Like

That error basically just means that the value you gave in with running is a nil value, meaning that isn’t a value. I don’t know because I’m more of a UI Designer, but go ahead and check the capitalization and also check like if its run, instead of running or something like that

Can you show us how you defined Humanoid?

True, there might be a problem with how you defined humanoid.

local Humanoid = Character:WaitForChild(“Humanoid”)

Also please tell how you defined character if possible

i dont have character defined.

well ok, then but the problem is with line 1 of the script but go check capitalization and check if it is run instead of running

the running part is,

Running

You don’t need a script and I think it is impossible to use destroy on it, in all SpawnLocation, change Duration to 0.
You can also do that and create it to change the parent at the right time.

From all your spawnlocations property, set ForceField Duration to 0. In StarterCharacterScripts, you can put in this script.

local Humanoid = script.Parent:WaitForChild("Humanoid", 5)

local ForceField = Instance.new("ForceField")
ForceField.Parent = script.Parent

Humanoid:GetPropertyChangedSignal("MoveDirection"):Wait()

ForceField:Remove()
script:Remove()

The script above is untested, but it should work. Humanoid’s move direction changes whenever the humanoid starts moving.

2 Likes

when i try to spawn it it will spawn me without forcefield

You spelt local humanoid = scipt

It actually is

local humanoid = script.Parent:WaitForChild(“Humanoid”, 5)

i get a issue with
ServerScriptService.Script:4: attempt to index nil with ‘Parent’

Are you sure you put it in StarterCharacterScripts…? You can find it in game > StarterPlayer > StarterCharacterScripts.

oh i thought to put it into server script service