Hello! I am trying to make a door which a certain rank of a group can go through but when I did it the door doesn’t seem to work. Can I know what is the problem? Here are the picture and the video
Did you tag the items with “Staffdoor”? If not, just select the parts you want, scroll down in properties, and add a tag named “Staffdoor”.
Idk whether this is considered tagged but this is what I got for the walls I wanted to tag
Add a wait before you go through the doors, it could just not be loading in enough time.
Code:
task.wait(1)
-- Rest of your code
local doors = ...
for i, v in doors ...
It would help if you pasted the code too, instead of just taking a screenshot.
And instead of doing .Transparency = 1
and .CanCollide = false
, can’t you just do :Destroy()
?
Thank you! I forgot that there is :Destroy() too! It works now!
Once the player joins, check them for their role. If the role is correct, send a ClientEvent through a RemoteEvent to them to make the door can collide off.
-- server
game.Players.PlayerAdded:Connect(function(player)
local rank = player:GetRankInGroup(GroupID)
if rank >= 5 then
game.ReplicatedStorage.RemoteEvent:FireClient(player)
end
end)
-- client
game.ReplicatedStorage.RemoteEvent.OnClientEvent:Connect(function()
local door = workspace.Door
door.CanCollide = false
door.Transparency = 1
end)
What you have is completely correct and should work. Please tell me if you have any problems.
I have an improvement in your script.
Instead of using RemoteEvents, you can just do this purely client-sided.
Remove your server script and remote event, and paste this inside your client script:
local Players = game:GetService("Players")
local CollectionService = game:GetService("CollectionService")
local LocalPlayer = Players.LocalPlayer
if LocalPlayer:GetRankInGroup(6279576) >= 5 then
CollectionService:GetInstanceAddedSignal("Staffdoor"):Connect(function(door)
door:Destroy()
end)
for i, door in CollectionService:GetTagged("Staffdoor") do
door:Destroy()
end
end
No waits are needed, and also no problem.
Thank you for the improvement! I will add it into the script! : D
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.