Server Main Walkable Wall Script

local defAnimStance = nil
local defRotation = nil
local defJumpVelocity = nil
-- switch player's movement on/off
local _playerSwitch = {nil}
_playerSwitch[0] = MovementControlMode.NONE
_playerSwitch[1] = MovementControlMode.VIEW_RELATIVE


function GBCheck(player,tname) -- check Gravity Boots hitting a wall
    if(player.isJumping == false) then -- player can't be jumping for this
        print("GB Check for "..player.name.." from wall trigger: "..tname)
        --_spawnTo = World.FindObjectByName("spawncube"..tostring(tname + 1)):GetWorldPosition() + Vector3.New(0,0,25)
        --_rotateTo = World.FindObjectByName("spawncube"..tostring(tname + 1)):GetWorldRotation()
        --player:ActivateFlying()
        --defRotation = player:GetWorldRotation()
        player.movementControlMode = _playerSwitch[0]
        --player.animationStance = "unarmed_walk_forward"
        player.canMount = false -- true/false => disallow mounting ability for now
        player.isCrouchEnabled = false -- true/false => disallow crouching for now
        player.maxJumpCount = 0 -- 0 or 1 -- disable jumping for now
        player.jumpVelocity = 100
        player:SetWorldRotation(player:GetWorldRotation() + Rotation.New(0, 90, 0))
        --Task.Wait(3)
        --player:AddImpulse(Vector3.RIGHT * player.mass * 500)
    end
end

function GBStop(player) -- check Gravity Boots stop working
    print("GB Stop for "..player.name)
    --player:ActivateWalking()
    player:SetWorldRotation(defRotation)
    player.animationStance = defAnimStance
    player.movementControlMode = _playerSwitch[1]
    player.canMount = true -- true/false =>
    player.isCrouchEnabled = true -- true/false => 
    Task.Wait(.5) -- keeps "jump" from activating
    player.maxJumpCount = 1 -- 0 or 1
    player.jumpVelocity = defJumpVelocity
end

Events.ConnectForPlayer("GBCheck", GBCheck)
Events.ConnectForPlayer("GBStop", GBStop)

Game.playerJoinedEvent:Connect(function(player)
    player.stepHeight = 400
    defAnimStance = player.animationStance
    defRotation = player:GetWorldRotation()
    defJumpVelocity = player.jumpVelocity
end)

Latest Posts