isc88
|
  |
| Joined: 30 May 2013 |
| Total Posts: 27545 |
|
|
| 21 Jun 2015 12:10 PM |
How could I do this? What I need to do is make a seat that only people in a certain rank of a group can sit in. Is this possible?
what siggy |
|
|
| Report Abuse |
|
|
| |
|
isc88
|
  |
| Joined: 30 May 2013 |
| Total Posts: 27545 |
|
|
| 21 Jun 2015 12:13 PM |
How would I do this :/
what siggy |
|
|
| Report Abuse |
|
|
|
| 21 Jun 2015 12:17 PM |
| Seats are really just parts, except when you touch them, your character is welded to it. Instead of using real seats, make some fake ones. Inside them should be a script that fires a function when the seat is touched. If the touching part belongs to a players' character, and that player is VIP, create a weld between the two. |
|
|
| Report Abuse |
|
|
isc88
|
  |
| Joined: 30 May 2013 |
| Total Posts: 27545 |
|
| |
|
|
| 21 Jun 2015 12:20 PM |
local VIPIds = { 123, 456 }
local seat = script.Parent
function isVip(player) for i,v in next, VIPIds do if player.userId == v then return true end end return false end
function getCharacterDescendant(instance) while instance and instance.ClassName ~= "Workspace" and instance.ClassName ~= "Model" do instance = instance.Parent end return instance.ClassName == "Model" and instance end
function seatChanged(property) if property == "Occupant" then local character = getCharacterDescendant(seat.Occupant) local player = game.Players:GetPlayerFromCharacter(character) if player and not isVip(player) then character:BreakJoints() end end end |
|
|
| Report Abuse |
|
|
|
| 21 Jun 2015 12:20 PM |
Im not sure if there's a way to access group ranks through scripts. One thing you could do is give everyone an intvalue, and number each player according to their rank (1 being leader, 2 being vice leader, etc)
i think your script would probably look something like this:
local script.parent.seat = seat
seat.OnTouched:connect(function(sit) local hum = sit.parent:FindFirstChild("Humanoid") if hum then if hum (is NOT in certain rank then) seat.Disabled = true
|
|
|
| Report Abuse |
|
|
isc88
|
  |
| Joined: 30 May 2013 |
| Total Posts: 27545 |
|
|
| 21 Jun 2015 12:22 PM |
@nq But that's not checking if the player is in a rank, that's just getting their IDs. It will work though, thank you.
what siggy |
|
|
| Report Abuse |
|
|
|
| 21 Jun 2015 12:23 PM |
| To get a player's rank in a script you can just do Player:GetRankInGroup(int GroupId) |
|
|
| Report Abuse |
|
|
|
| 21 Jun 2015 12:24 PM |
This works with Rank.
local GroupId = 0 local RankNeeded = 255 -- Must be this rank or above to use the seat
local seat = script.Parent
function canUseSeat(player) if player:GetRankInGroup(GroupId) >= RankNeeded then return true end return false end
function getCharacterDescendant(instance) while instance and instance.ClassName ~= "Workspace" and instance.ClassName ~= "Model" do instance = instance.Parent end return instance.ClassName == "Model" and instance end
function seatChanged(property) if property == "Occupant" then local character = getCharacterDescendant(seat.Occupant) local player = game.Players:GetPlayerFromCharacter(character) if player and not canUseSeat(player) then character:BreakJoints() end end end |
|
|
| Report Abuse |
|
|