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

How do i can get out of the Seat Object?

Asked by 2 years ago

i made a seat script that only allow me to sit in it, but when i sit i cant get out, wt can i do for just get out with "space" for example?

local allowed = {438845010}
local players = game:GetService("Players")

local seat = script.Parent

seat.Disabled = true

seat.Touched:Connect(function (hit)
    if seat.Occupant then return end
    local player = players:GetPlayerFromCharacter(hit.Parent)
    for i = 1, #allowed do
        if allowed[i] == player.UserId then
            local humanoid = player.Character:FindFirstChildWhichIsA("Humanoid")
            if humanoid then
                seat:Sit(humanoid)
            end
            break
        end
    end
end)
0
Why not use the Seat object Roblox provides by default? SuperLittleAdmin 257 — 2y
0
but can i do it for only me sit? like, no one can sit in it, ppl will touch but not sit and pose. if yes, how? Ariirael 15 — 2y

1 answer

Log in to vote
0
Answered by 2 years ago

You should add simple scripts in this situation your script is too complicated and has more chances to error instead what you can do is:

local Owner = "Ariirael"

script.Parent.ChildAdded:Connect(function(PartAdded)
    if PartAdded.Name == "SeatWeld" then
        local Name = PartAdded.Part1.Parent.Name
        if Name == Owner then
            print(Name.." the owner is sitting")
        else
            wait()
            local Player = PartAdded.Part1.Parent
            Player:FindFirstChild("Humanoid").Sit = false
            print(Player.Name.." was prevented from sitting")
        end
    end
end)

I Hope This Helps!

Ad

Answer this question