Script help - detection

how do i make it so the script detects if someone is sat on a certain seat?

Use this:

local Seat =  script.Parent -- Path to seat

Seat:GetPropertyChangedSignal("Occupant"):Connect(function()
   if Seat.Occupant ~= nil then
-- your script
   end
end)
1 Like

the seat has a error on it-- -

1 Like

Can you tell me what you want to do if the player sits on the chair, may be i can help :smiley:

1 Like

you have to make your own Seat Variable.

local YourSeat = -- Here
YourSeat:GetPropertyChangedSignal("Occupant"):Connect(function()
if YourSeat.Occupant ~= nil then
-- code
end
end)
2 Likes

when the player sits on the seat, if they’re below rank 2 then theyll jump and get a tshirt prompt

1 Like
local YourSeat = script.Parent
local ShirtID = 1 -- Change To Your Shirt ID
local GroupID = 1 -- Change To Your Group ID
YourSeat:GetPropertyChangedSignal("Occupant"):Connect(function()
if YourSeat.Occupant ~= nil then
local hum = YourSeat.Occupant
local plr = game.Players:GetPlayerFromCharacter(hum.Parent)
if plr then
if plr:GetRankInGroup(GroupID) < 2 then
hum.Jump = true
game:GetService("MarketplaceService"):PromptPurchase(plr,ShirtID)
end
end)
2 Likes
local Seats = workspace.Folder:GetChildren()

for _, v in pairs(Seats) do
	v:GetPropertyChangedSignal("Occupant"):Connect(function()
		if v.Occupant ~= nil then
			print(v.Name)
		end
	end)
end
1 Like
local Seat =  script.Parent -- Path to seat
local ShirtID = 1 -- your shirt ID
local GroupID = 1 -- your group ID

Seat:GetPropertyChangedSignal("Occupant"):Connect(function()
   if Seat.Occupant ~= nil then
      local hum = Seat.Occupant.Parent
      local player = game.Players:GetPlayerFromCharacter(hum.Parent)
         if player then
             if player:GetRankInGroup(GroupID) < 2 then
               hum.Jump = true
               game:GetService("MarketPlaceService"):PromtPurchase(player, ShirtID)
            end
        end
    end
end)
1 Like

kk

what do you mean by the folder the value is in what value

1 Like

The rank in game or the rank in the group?

1 Like

did you even try my script yet?

1 Like

rank in group


1 Like

yeah it had errors and didnt work --------

1 Like

you have to change YourSeat to your Seat. as well as the Shirt ID and the Group ID

1 Like

Now I think It should work [I’m literally replying to so many messages so there can be errors]

1 Like

you know what,
try this
put this inside your seat and change the IDS to your IDS.

local YourSeat = script.Parent
local ShirtID = 1 -- Change To Your Shirt ID
local GroupID = 1 -- Change To Your Group ID
YourSeat:GetPropertyChangedSignal("Occupant"):Connect(function()
if YourSeat.Occupant ~= nil then
local hum = YourSeat.Occupant.Parent
local plr = game.Players:GetPlayerFromCharacter(hum.Parent)
if plr then
if plr:GetRankInGroup(GroupID) < 2 then
hum.Jump = true
game:GetService("MarketPlaceService"):PromptPurchase(plr,ShirtID)
end
end
end
end)
1 Like

Should be working now!

local Seat =  script.Parent -- Path to seat
local ShirtID = 1 -- your shirt ID
local GroupID = 1 -- your group ID

Seat:GetPropertyChangedSignal("Occupant"):Connect(function()
   if Seat.Occupant ~= nil then
      local hum = Seat.Occupant.Parent
      local player = game.Players:GetPlayerFromCharacter(hum.Parent)
         if player then
             if player:GetRankInGroup(GroupID) < 2 then
               hum.Jump = true
               game:GetService("MarketPlaceService"):PromtPurchase(player, ShirtID)
            end
        end
    end
end)
1 Like

Yes they do look similiar but I didn’t copy it :smiley: [As you can see your code has some errors in it]

1 Like

nope didnt work

local Seat = script.Parent.premseatscript – Path to seat
local ShirtID = 10453709879 – your shirt ID

Seat:GetPropertyChangedSignal(“Occupant”):Connect(function()
if Seat.Occupant ~= nil then
local hum = Seat.Occupant.Parent
local player = game.Players:GetPlayerFromCharacter(hum.Parent)
if player then
if player:GetRankInGroup(15554654) < 2 then
hum.Jump = true
game:GetService(“MarketPlaceService”):PromtPurchase(player, ShirtID)
end
end
end
end)

1 Like