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 can get out of the Seat Object?

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)

2 comments

0

Why not use the Seat object Roblox provides by default?

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?

1 answer

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!

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