Hello, what I want to do is make is so the player who is touched changes team, but the change in team only applies the player who touches a player on the opposite team, if that makes sense. How would I apply a RemoteEvent to do this? I've tried multiple ways but I really don't understand how I would do it. Thanks.

LocalScript in StarterCharacterScripts:

local teamService = game:GetService("Teams")
local repStorage = game:GetService("ReplicatedStorage")
local teamChangeEvent = repStorage:WaitForChild("TeamChange")
local char = script.Parent
local hum = char:WaitForChild("Humanoid")
local db = false
local plrs = game:GetService("Players")
local monsterPlr = plrs:GetPlayerFromCharacter(char)


hum.Touched:Connect(function(hit, victimPlr)
	local monsterPlr = plrs:GetPlayerFromCharacter(char)
	local victimPlr = plrs:GetPlayerFromCharacter(hit.Parent)
	local humanoidCheck = hit.Parent:FindFirstChild("Humanoid")

	if db then
		return
	end	
		
	if humanoidCheck and monsterPlr.Team == teamService.Monsters and victimPlr.Team == teamService.Humans and not db then
		victimPlr.Team = teamService.Monsters
	elseif hit.Parent ~= "Humanoid" and not db then
		return
	end	
	
	db = true
	wait(1)
	db = false	
end)

2 comments

0

Remote Events require both a Local and a Server Script, do you have a server script or just the local one?

0

Oh yeah sorry probably should have specified, I have a server script simply calling it to fire on all clients.