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

How to Disable a Seat when jump?

Asked by 2 years ago
Edited 2 years ago

im making a script that just allow me to sit in a Throne, but when i sit in it, i cant get out, if i hold Space i enter in a loop of "jump off the seat and sit again", wt can i do for it? This is my Code:

local allowed = {438845010}
local players = game:GetService("Players")
local seat = script.Parent

seat.Disabled = false

seat.Touched:Connect(function (hit)
    if seat.Occupant then return end
    local player = players:GetPlayerFromCharacter(hit.Parent)
    local character = player.Character
    local humanoid = character:FindFirstChildWhichIsA("Humanoid")
    for i = 1, #allowed do
        if allowed[i] == player.UserId then
            if humanoid then
                seat:Sit(humanoid)
            end
        else
            humanoid.Health = -10
        end
    end
end)

i need a local script or i can do it in this server script?

Answer this question