Hi everyone. I wanna make this clickable only for rankId that is 100 and above. They can only click the click detector. Does anyone know how to do it?
Here is the script:
function onClicked(playerWhoClicked)
if game.Workspace.Fireworks1.FireworksClassicStyle.Trigger.Value == false then
game.Workspace.Fireworks1.FireworksClassicStyle.Trigger.Value = true
if game.Workspace.Fireworks2.FireworksClassicStyle.Trigger.Value == false then
game.Workspace.Fireworks2.FireworksClassicStyle.Trigger.Value = true
if game.Workspace.Fireworks3.FireworksClassicStyle.Trigger.Value == false then
game.Workspace.Fireworks3.FireworksClassicStyle.Trigger.Value = true
if game.Workspace.Fireworks4.FireworksClassicStyle.Trigger.Value == false then
game.Workspace.Fireworks4.FireworksClassicStyle.Trigger.Value = true
end
end
end
else
game.Workspace.Fireworks1.FireworksClassicStyle.Trigger.Value = false
game.Workspace.Fireworks2.FireworksClassicStyle.Trigger.Value = false
game.Workspace.Fireworks3.FireworksClassicStyle.Trigger.Value = false
game.Workspace.Fireworks4.FireworksClassicStyle.Trigger.Value = false
end
end
script.Parent.MouseClick:Connect(onClicked)
First of all, I’d put all these fireworks inside of a Folder in workspace, for organization and for better ease with scripting in the game.
You will then be able to get all of the fireworks from that folder and have the checks you need, and in the end, apply the changes.
script.Parent.MouseClick:Connect(function(plr)
if plr:GetRankInGroup(GROUP ID) >= 100 then --Insert your group's ID here, checking if its number 100 or above
for i, v in pairs(workspace.Fireworks:GetChildren()) do --Gets all the children from that folder (not descendants) and applies changes
if v.FireworksClassicStyle.Trigger.Value then
v.FireworksClassicStyle.Trigger.Value = false
else
v.FireworksClassicStyle.Trigger.Value = true
end
end
end
end)
What you also did wrong is have checks (if statements) inside of other if statements, to check if the other values are false. That would make a problem. If your Firework1 would of been true, the other false fireworks couldn’t change their value. But you’ve made it so all values become false, so that is another way I guess. That’s why I scripted in a different way, it’s like a suggested way, if you don’t want it this way, simply write the GROUP check and you are done.
I hope this helped you, good luck with your project.