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

Rank door do not work for a rank it is supposed to work, but it works for an higher rank. Why?

Here is the script:

local GroupId = 4565372
local RankId = 6

script.Parent.Touched:connect(function(part)
	if part.Parent and game:GetService('Players'):GetPlayerFromCharacter(part.Parent) then
		local player = game:GetService('Players'):GetPlayerFromCharacter(part.Parent)
		if player:GetRankInGroup(GroupId) >= RankId then
			script.Parent.Transparency = 0.8
			script.Parent.CanCollide = false
			wait(0.65)
			script.Parent.Transparency = 0.5
			script.Parent.CanCollide = true
		end
	end
end)

It does not work for the rank with the rankid 6, but works for a rank with the rankid 255 (the owner), but when the rank with the rankid 6 tries to pass the door, the door changes transparency but does not let the player.

2 comments

0

i tried the script and it works just fine

0

Really?

1 answer

Try to pcall the code. pcalling tests the code if there is an error, if there is, it'll print it to the output. I hope it helps. i wasn't able to find the problem.. good day!

local s, e = pcall(function()
local GroupId = 4565372
local RankId = 6

script.Parent.Touched:connect(function(part)
    if part.Parent and game:GetService('Players'):GetPlayerFromCharacter(part.Parent) then
        local player = game:GetService('Players'):GetPlayerFromCharacter(part.Parent)
        if player:GetRankInGroup(GroupId) >= RankId then
            script.Parent.Transparency = 0.8
            script.Parent.CanCollide = false
            wait(0.65)
            script.Parent.Transparency = 0.5
            script.Parent.CanCollide = true
        end
    end
end) end) if not s == true then warn(e) end --this will print the error in the output in orange,
--I wasn't able to find it :(

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