Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Script that removes you from a seat if you're not in a specified rank in a specified group?

Hello I recently made this script. Basically if you're not in a specified rank in a specified group the script will remove you from the seat. The script I made isn't working and I honestly don't know why. Can someone help me? The script is a children of DriverSeat.

script.Parent.Changed:Connect(function()
	if script.Parent.Occupant then
		local human = game.Players:FindFirstChild("Humanoid")
		if (human ~= nil) then
			if game.Players[human.Parent.Name]:GetRankInGroup(3403693) >= 13 then -- rank group and id are random
				else human.Jump = true
				wait(0.5)
			end
		end
	end
end)

2 answers

Localscript in StarterPlayer > StarterCharacterScripts

Also, make the "SeatNameHere" the name of your seat so it should work.

script.Parent:WaitForChild("Humanoid").Seated:Connect(function(active, seat)
	if active and seat.Name == "SeatNameHere" then
		if game.Players.LocalPlayer:GetRankInGroup(3403693) >= 13 then
			
			else
			script.Parent.Humanoid:ChangeState(Enum.HumanoidStateType.Jumping, true)
			wait(0.5)
		end
	end
end)

2 comments

0

This can be exploited since it's client-sided.

0

You could always just have the seat local to players who are alowed to sit in it, and just have a part where it is that is global.

Making explanation Right now, just wait

Script:

local Seat = script.Parent -- Get seat
local Players = game:GetService("Players") -- Get players
local Player -- Define player 
Seat:GetPropertyChangedSignal("Occupant"):Connect(function() -- When the seat occupant changes
	if Seat.Occupant then -- If there's an occupant
		Player = Players:GetPlayerFromCharacter(Seat.Occupant.Parent) -- Get player
		if Player:GetRankInGroup(3403693) < 13 then -- rank group and id are random
			Occupant.Jump = true -- Make them jump
		end
	else
		Player = nil -- set player to nil
	end
end)

1 comment

0

Occupant.Jump in the line 8 gives error: attempt to index nil with 'Jump'

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