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

The Script goes good until then?

Asked by
Valiux 27
8 years ago

Please provide more explanation in your question. If you explain exactly what you are trying to accomplish, it will be much easier to answer your question correctly.
local ExecutiveDoor = script.Parent


game.Players.PlayerAdded:connect(function(Player)
    if Player:GetRankInGroup(2801587) == 50> then
    script.Parent.CanCollide = false
    wait(1.5)
    script.Parent.CanCollide = true

end

2 answers

Log in to vote
1
Answered by 8 years ago
Edited 8 years ago

Due to no background explanation of what you wanted this to do, it makes it a little more tricky to explain...


However from looking at it, your problem is in line 5: if Player:GetRankInGroup(2801587) == 50> then

Your error is == 50> then

What I think you were trying to do was to see if the player's Rank was equal to or higher than 50... Which in your code only checks equal to because the greater than sign is on the wrong side of the number.

To fix this you'll need to remove one of the equal signs and replace that with your greater than...

local ExecutiveDoor = script.Parent

game.Players.PlayerAdded:connect(function(Player)
    if Player:GetRankInGroup(2801587) >= 50 then
    script.Parent.CanCollide = false
    wait(1.5)
    script.Parent.CanCollide = true
    end
end)

If this has answered your question, please accept the answer with the button on the right... If it doesn't work do let me know and I'll fix it and if you want a better explanation please do ask!


On a side note, This is for a door... With this script the door will open every time a player that satisfies the requirements joins meaning anyone could walk through it when it opens... I'd suggest using the onTouchedfunction rather than PlayerAdded... Some more about this can be read up here.

1
Ew don't say onTouched, call it by its proper name ".Touched" itsJooJoo 195 — 8y
Ad
Log in to vote
0
Answered by
einsteinK 145
8 years ago
Edited 8 years ago

You forgot an 'end' and at line 5 you have a '>' where you shouldn't have one. Your if-statement gets closed at line 10, but your function (04-...) doesn't get closed. Either you do 'if VALUE == 50' or 'if VALUE > 50' but not what you're doing there.

Maybe you want something like this:

local ExecutiveDoor = script.Parent

game.Players.PlayerAdded:connect(function(Player)
    -- Check if their rank is higher than 50 (not including 50)
    -- (if you want to include 50, use >= instead of > here)
    if Player:GetRankInGroup(2801587) > 50 then
        script.Parent.CanCollide = false
        wait(1.5)
        script.Parent.CanCollide = true
    end
end)

I assume this is for a door, which makes me think you're doing it completely wrong. When a player joins with the right rank, the door opens for 1.5s, but that's it. You might wanna read this wiki article: http://wiki.roblox.com/index.php?title=Restricted_door You could edit it to work with the rank instead of owning a gamepass or something.

Answer this question