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

How do you make a Life Vest-type-tool?

Asked by
oftenz 367 Moderation Voter
6 years ago

Hello everyone this is my first question. I am making a diving game and am wanting to make a Life Vest. I want it to force the player to the top of the water and I have no idea how to do this. Any help?

1 answer

Log in to vote
1
Answered by
oftenz 367 Moderation Voter
6 years ago

Solved this by myself. Here is my code in a Local Script. -

local p= game.Players.LocalPlayer
local tool= script.Parent
local State
local Info = true
local StateHelp = true

function equipped()
    Info = true
    StateHelp = true
    while Info == true do
    wait()
    State = p.Character.Humanoid:GetState() 

    if State == Enum.HumanoidStateType.Swimming then
        if StateHelp == true then
    script.Parent.BodyPosition.Parent = script.Parent.Handle
    end
    StateHelp = false
end
    end
end

function unequipped()
    wait()
    Info = false
    if StateHelp == false then
    script.Parent.Handle.BodyPosition.Parent = script.Parent
    end
end

tool.Equipped:connect(equipped)
tool.Unequipped:connect(unequipped)
Ad

Answer this question