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

How do i make a forcefield block?

Asked by 2 years ago

I want to make a block where whenever your touching it, it gives you a forcefield but when you get off of the block it goes away, this is my code

local forcePart = script.Parent

local canActivate = true



local function forceField(otherPart)

    local humanoid = otherPart.Parent:FindFirstChild('Humanoid')

    if humanoid and canActivate then

        canActivate = false

        forcePart.Transparency = 1

        forcePart.CanCollide = false

        local force = Instance.new('ForceField')

        force.Parent = humanoid.Parent

        wait(5)

        forcePart.Transparency = 0

        forcePart.CanCollide = true

        force:Destroy()

        canActivate = true

    end

end



forcePart.Touched:Connect(forceField)

1 answer

Log in to vote
0
Answered by 2 years ago

My guess would be because you disable the part's collision which causes it to fall through the map, If you don't have to move it you should anchor the part.

Ad

Answer this question