Why is this the best way? What’s your proof that local door is worse than collision group door?
Local door is the best solution in this case as it is easy to implement and efficient when it comes to server load.
You would Connect to a CharacterAdded event and then check if the players group rank is higher than 4 if it is add all the part of the character into a Collision group and the door in another or the same collision group and then Make it so the Collision group(s) can’t collide with each other
I agree, and my script works, I have tested it in studio.
It would run just fine under a server script, since it runs after player.added() which gives you the player’s player.
You can just check if:
if game.Players.LocalPlayer:GetRankInGroup(4880128) >=4 then
StaffDoor1.CanCollide = false
StaffDoor2.CanCollide = false
StaffDoor3.CanCollide = false
else
end
Don’t need to wait for the player to be added because starter player scripts automatically does this ( they run once the player is added! ).
No it won’t in a sever script. If Someone joins with a higher rank than 4 the doors cancollide will be false for Everyone
Please do not post on the devforum if you do not know what is going on in the topic or have no necessary knowledge.
Exactly what I have done.
And It does work.
In the group:
robloxapp-20200419-2031161.wmv (716.3 KB)
Outside the group:
robloxapp-20200419-2031497.wmv (708.5 KB)
But as I understood, he wants only group members to get in.
Why not change it to:
if game.Players.LocalPlayer:GetRankInGroup(4880128) >=4 then
StaffDoor1.CanCollide = false
StaffDoor2.CanCollide = false
StaffDoor3.CanCollide = false
else
StaffDoor1.CanCollide = true
StaffDoor2.CanCollide = true
StaffDoor3.CanCollide = true
end
But he specified what he is trying to achieve “I want it so all ranks with a rank ID of 4 or higher can go through this part, which is invisble.”
It’s started working! Marked it as solved.
My script works just fine, and csimple, that addition is great, I have not added that.
local StaffDoor1 = game.Workspace.GroupDoor1
local StaffDoor2 = game.Workspace.GroupDoor2
local StaffDoor3 = game.Workspace.GroupDoor3
local Player = game.Players.LocalPlayer
if Player:GetRankInGroup(4880128) >=4 then
StaffDoor1.CanCollide = false
StaffDoor2.CanCollide = false
StaffDoor3.CanCollide = false
else
StaffDoor1.CanCollide = true
StaffDoor2.CanCollide = true
StaffDoor3.CanCollide = true
end
Thanks, very much appreciated.
On another note, if you don’t want to use collision groups you can just teleport players away from the door if they don’t meet the rank.
But I am not sure if it’s needed though, because the if fires only if the player has the rank and in the group.
And it fires only for the player.
Yeah, it’s not necessary to run the else statement. But this script I believe does do what he wanted, so Im unsure what others meant by saying this was a misleading piece of code?
This could be used as a secondary precaution for more security!
What you can do is try to make it a server script, then when a player touches a door, you fire a remote function, which a local script will then check the persons group rank id, then return true/false. Then you run an if statement, and if the callback is true, then the door has CanCollide set to false, wait a few seconds, then set back to true. What you can also do is when the door is open, and someone walks through, run the same function, and if false, respawn the player. I’m not exactly familiar with Remote Functions in terms of how they work, but I know what they do.
So you fire a remote to the client, and back to the server? Why is it needed?
Edit: I got it wrong, that can work, but it is not needed, because the local player already is the player, there’s no need for the server script.