Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

This script is not working for me?

Asked by 9 years ago

Please make your question title relevant to your question content. It should be a one-sentence summary in question form.

Hello. I added lines to the script, so instead of letting players pass doors who are from my group, instread it lets door be passed by specific ranks on my group, so i changed the script a bit, but now the doors are not working at all!

01CurrentGroup = 2684229 -- Change this to GroupID of your group
02Door = script.Parent -- Do not modify
03IsActive = false -- Do not modify
04KillOnContact = false -- If true, kills non group members, if false does not let them in.
05WaitTime = 2 -- Amount of time door remains open
06G1 = script.Parent.Parent.Green1
07G2 = script.Parent.Parent.Green2
08R1 = script.Parent.Parent.Red1
09R2 = script.Parent.Parent.Red2
10 
11 
12function Touched(Part)
13    if IsActive then return end
14    IsActive = true
15    if Part.Parent then
View all 54 lines...
0
Read the output. Lines 18-21 aren't even finished. 1waffle1 2908 — 9y

1 answer

Log in to vote
0
Answered by 9 years ago

GetRankInGroup can and sometimes is sketchy to be used. I consider using GetRoleInGroup instead. It is basically the same except instead of returning the RankId of the player, it returns the role name.

So lets say for instance ( this is just an example script ), you have a group with the ID of 2525294. In that group with said ID you have a rank called "MLG"

Here is how it would check if the player is in that group ( place script in a wall part )

01script.Parent.Touched:connect(function(hit)
02    if game.Players:FindFirstChild(hit.Parent.Name) then
03        local player = game.Players:FindFirstChild(hit.Parent.Name)
04        print("is a player")
05        if player:IsInGroup(2525294) then
06            print("player is in group")
07            if player:GetRoleInGroup(2525294) == "MLG" then
08                print("player is in group and the role of him/her is MLG")
09                script.Parent.CanCollide = false
10                wait(2)
11                script.Parent.CanCollide = true
12            end
13        end
14    end
15end)

Hope this helped!

0
Just an fyi, lines 18-21 are not complete, you wrote 3 different if's without then's in a single if statement. You can combine this all like: disassembling 48 — 9y
0
if player:IsInGroup(CurrentGroup) and player:GetRankInGroup(CurrentGroup) == 255 or 254 or 80 then disassembling 48 — 9y
0
@disassembling thanks for telling this method. I didnt know that you can use after the == multiple values. Also, could the multiple values after == work with GetRoleInGroup too or no? CraftioLo 0 — 9y
Ad

Answer this question