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 make a forcefield block?

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

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.

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