Issue with Group Rank Vehicle Seat

We are trying to create a group rank only script but for some odd reason this won’t work. Does anyone have any idea why?


local Seat = script.Parent

Seat:GetPropertyChangedSignal("Occupant"):Connect(function()
 local Player = game.Players:GetPlayerFromCharacter(Seat.Occupant.Parent)

if Player and Player:GetRankInGroup(GroupID) < 5 then
Seat.Occupant.Jump = true
 end
end)

Have you tried destroying the SeatWeld?
https://create.roblox.com/docs/reference/engine/classes/Seat

1 Like

Ill try it and see if it will work. :slight_smile:

This script should be what you are looking for… i hope.

Since this is a little bit fast the player wont actually get to sit in the seat as it destroys the weld almost instantly…
If you would like the player to sit in the seat for a second before it is destroyed then increase the task.wait() to 1 or more seconds.

local Players = game:GetService("Players")

local GroupID = 1234 --change this
local Seat = script.Parent

local function seatRankCheck()
	if Seat.Occupant ~= nil then --makes sure the seat isnt empty
		local Hum = Seat.Occupant
		local Char = Hum.Parent 
		local Player = Players:GetPlayerFromCharacter(Char)
		if Player:GetRankInGroup(GroupID) < 5 then
			task.wait(0) 
			--stops the weld destroying instantly which causes issues, increase this to 1 if you want the player to actually sit for a second
			Seat:FindFirstChild("SeatWeld"):Destroy()
			print("not high enough rank!")
			--you can get rid of this if you like
		end
	end
end

Seat:GetPropertyChangedSignal("Occupant"):Connect(seatRankCheck) 
--this is what fires the function, stick this where ever in the script, as long as it is below the actual function

Cheers. Ill test it later. We did manage to get it working but ill see if it works later as it may be more efficient than what we actually have. I’ll mark it as a solution once I’ve tested. :slight_smile:

Forgot to mark anything as solution. We re-scripted the whole system and it now works

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.