I’m trying to make it so if you have a certain rank in the group or above you can access the button. This button opens a tweened door.
If possible how would I add a cooldown for that user only?
Here is my current code that doesn’t work to open this door.
local groupId = 7211189 --use your group id
local requiredRank = 3 --enter the required rank(like 255, for example)
local Service = game:GetService("TweenService")
local Gate = script.Parent.Parent.cell1
local Allowed = {
1614394440,1287679593 -- your userID
}
local Info = TweenInfo.new(8)
script.Parent.ClickDetector.MouseClick:Connect(function(hit)
for i,v in pairs(Allowed) do
if hit.UserId == v then
print("allowed")
script.Parent.CanCollide = false
local Change = {Position = Vector3.new(77.225, 5.61, 91.93)}
local Tween = Service:Create(Gate, Info, Change)
Tween:Play()
end
end
end)
Yes, you can add a cool down. The way I use cool downs is by adding a Bool-Value or String-Value into the character and naming it “CoolDown” or something, the way you can add it into the character is by creating a new instance of a bool value or any value and parent it to the character and then deleting it after the amount of time the cool down is has passed, you can delete it by using the game.Debris:AddItem() function. So to do this, on the if statement you could add this after the ‘v’ hit.Character:FindFirstChild(“CoolDown”) == nil and you would add the value instance right under the if statement! If you have any questions please lmk!
local groupId = 7211189 --use your group id
local requiredRank = 3 --enter the required rank(like 255, for example)
local CoolDownTime = 5 -- Put your cool down time here
local Service = game:GetService("TweenService")
local Gate = script.Parent.Parent.cell1
local Allowed = {
1614394440,1287679593 -- your userID
}
local Info = TweenInfo.new(8)
script.Parent.ClickDetector.MouseClick:Connect(function(hit)
for i,v in pairs(Allowed) do
if hit.UserId == v and hit.Character:FindFirstChild("CoolDown") == nil then
local b = Instance.new("BoolValue", hit.Character)
b.Name = "CoolDown"
print("allowed")
script.Parent.CanCollide = false
local Change = {Position = Vector3.new(77.225, 5.61, 91.93)}
local Tween = Service:Create(Gate, Info, Change)
Tween:Play()
game.Debris:AddItem(b,CoolDownTime)
end
end
end)
Also, sorry if I’m explaining things incorrectly or it’s just wrong. I just got verified to be a member like 20ish minutes ago and this is my first helpful reply thing lol. Again, I’m sorry if I’m explaining it poorly. Thanks!
local groupId = 7211189 --use your group id
local requiredRank = 3 --enter the required rank(like 255, for example)
local Service = game:GetService("TweenService")
local Gate = script.Parent.Parent.cell1
local Allowed = {
1614394440,1287679593 -- your userID
}
local Info = TweenInfo.new(8)
script.Parent.ClickDetector.MouseClick:Connect(function(hit)
for i,v in pairs(Allowed) do
if hit.UserId == v then
print("allowed")
script.Parent.CanCollide = false
local Change = {Position = Vector3.new(77.225, 5.61, 91.93)}
local Tween = Service:Create(Gate, Info, Change)
Tween:Play()
end
end
end)
Yeah, no this script works perfectly fine for me. I tested it in studio, I put my own group ID the required rank and I put my user ID in the allowed section. I don’t know why it is not working for you because it works for me, I even checked my character model and the CoolDown value is inside it so idk. So make sure you put your user ID inside, your group ID and your group required rank.
Oh, you said the code doesn’t work to open the door you edited and I didn’t read. You have to put a group ID that you are in, the required group rank number AND your user ID. If you don’t put those 3 it won’t work. The cool down also works you just have to put the correct ID’s.