I'm trying to make a city roleplay game, and I have a spawner that when you stand on the button its spawn the vehicle, want to make a script that when you stand on the button the script makes sure that you are in the right team, and if you are in the right team it spawns the vehicle, can't really make it. Here's a screen of the spawner I have https://prnt.sc/ynvvh4 can someone help me please. ;-; https://prnt.sc/ynvvh4
✓ ANSWER ACCEPTED
How to make a team only button for my vehicle spawner? Please Help!
1 answer
✓ Accepted answer
You would get the player from the Character, since you can check their team inside the player, Here is the script I used to do so.
local part = script.Parent
local Players = game:GetService("Players")
-- Variables
part.Touched:Connect(function(hit) -- Runs when part gets touched
local Character = hit.Parent -- Gets the Character or model of player
local player = Players:GetPlayerFromCharacter(Character) -- Gets Player
local Teams = game:GetService("Teams") -- Gets Teams Service
if player.TeamColor == Teams.TeamNameHere.TeamColor then -- Checks if Player is on Corresponding Team
print("Corresponding team")
-- You can do whatever you want to do in here
end
end)
-- Made by a Script inside the Part that will be touched
This discussion is preserved as it was. New answers, comments, and votes are closed.
