Hello! I made a script that opens a door up, now the script works when you click the ClickDetector, yet I don’t want anyone able to use the ClickDetector…I want a specific team to be able to click it, and make it work.
Slight issue…I don’t know how to make this.
I tried one thing. I tried this;
local plr = game:GetService("Players").LocalPlayer
script.Parent.Button1.ClickDetector.MouseButton1Click:Connect(function()
if DoorStatus == "Closed" and Debounce == false and plr.TeamColor = "Color" then
And it didn’t work… :[
I need some help with this, if someone could give me a working version of this, or if you could give me a hint towards the right answer, that’d be great.
Anticipating/patiently waiting on your reply, lcey.
local plr = game:GetService("Players").LocalPlayer
local Teams = game:GetService("Teams")
script.Parent.Button1.ClickDetector.MouseButton1Click:Connect(function()
if DoorStatus == "Closed" and Debounce == false and plr.Team == Teams["TeamName"] then
end
end)
Have the ClickDetector in workspace always set to 0, use a server script to determine players on the correct team, fire an event to the player, where their local script raises the MaxActivationDistance!
local teams = game:GetService("Teams")
local team = teams.Team --Team named "Team".
local clickDetector = script.Parent
clickDetector.MouseClick:Connect(function(player)
if player.Team == team then --This team can use the ClickDetector.
--Reward player?
else
--Kill player?
end
end)
You’d check the team property of the player that clicked on the ClickDetector instance which resulted in its “MouseClick” event firing.
Thank you! Adding the extra shebang to either kill or reward can help. My question was already answered by an early answerer. I already have a full code setup where if they aren’t that team, it just doesn’t work. I just posted a snippet here where I needed the team part, yet the rest of the code isn’t here. Thank you though! Keep helping people out! Your doing good.
Thank you!! All support is appreciated. Your script looks a bit more complicated than the kind person who answered earlier with a short, & simple code. Yours is a great alternative option if his/hers doesn’t work. Keep doing what your doing, it’s amazing. -lcey
I love you! Thank you so much, you helped me out a lot. My thanks to you as my game works properly as it should. My two other developer friends, aswell as players on the team that keeps being disturbed all thank you.
This would work, and is super simple to code the ServerScript that I am able to do. YET this is a last resort for me due to there being quite a few ways to do it within the script inside of the door model that opens & closes. This would be a last resort because it just yk, is a more complicated than needed. Love you bro, keep going with what your doing. I encourage you to help others in need every chance you get, peace!
Yeah click detectors are great because they are difficult to exploit. Not a lot of exploits on them. The client just sees them and when you click on it it will tell the server you clicked. But then the server can decide if it wants to take your click or just ignore your click. In this case it will take the click if the clicker is on the right team.
It works! Thank you so much, keep up the good work. I couldn’t figure it out, yet you could. Guess that’s why my role is a modeler, not a scripter. Again, THANK YOU!