My local script is taking over things

So… My local script in starterplayerscripts is literally not letting ANY other scripts work. or it might not be the local script. So I made a thing so if you touch a part, you do a animation and u become the “infected” team. Just like transfurmation right… So I’m trying to make it so if you die, or touch a certain block, you become the Humans team. but my local script isn’t allowing that…

Note: there are literally NO errors…

My local script:

local Folder = workspace.Infectors -- Change to your folder 
local Animation = game.Workspace.Animation
local player = game.Players.LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()
local hum = char:WaitForChild("Humanoid")

for Index, Part in pairs(Folder:GetChildren()) do
		if touched.Parent:FindFirstChild("Humanoid") then
			local AnimPlay = touched.Parent.Humanoid:LoadAnimation(Animation)
			touched.Parent.HumanoidRootPart.Anchored = true
			AnimPlay.Stopped:wait() --Waits until it finished playing
			touched.Parent.HumanoidRootPart.Anchored = false
			player.TeamColor ="Really red")
			if player.TeamColor =="Really red") then
				script.Disabled = true
				if player.TeamColor =="White") then
					script.Disabled = false

The touch block to become Human Team script:

local team ="White")
local part = script.Parent

	local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
	if plr then
		plr.TeamColor = team

Is the Human Team script a local or server script?

You can’t change a players team on the client. You need to do it on the server by utilising remote events and sending whatever data you need to the server.

sever script, inside the part.

so what do I do then.
Steps pls?

You should honestly just make everything server sided using a script. I don’t see why you need a local script at all. You can get the player from the hit part and basically do whatever you did in the local script.

Also, I see a huge issue happening here with your local script. So basically, when the .Touched connection runs, it will affect the Local Player, not the “touched” connection. I would rather do all of this from one server script

the reason im using a local script is because I can’t redo this using a normal script, if I were to then I would need insane amount of help.

What would be hard about it? Is there something messing up whenever you tried to make it server sided?

no it’s just idk how to do it using server sided

local Folder = workspace.Infectors
local cache = {}

        cache[plr] = false

for _, part in pairs(Folder:GetChildren()) do
        local char = hit:FindFirstAncestorOfClass("Model")
        local hum, humpart = char.Humanoid, char.HumanoidRootPart
        local plr = game.Players:GetPlayerFromCharacter(char)
        if part.Name == "InfectedTeam" then --change this for infected team
            if not cache[plr] then
                cache[plr] = true

                if hum:FindFirstChildOfClass("Animator") ~= nil then

                humpart.Anchored = true

                local animator, anim = Instance.New("Animator", hum),"Animation")
                anim.AnimationId = --PUT ID HERE
                anim.Priority = Enum.AnimationPriority.Action
                anim.Priority = Enum.AnimationPriority.Core
                humpart.Anchored = false
                plr.TeamColor ="Really red")
        elseif part.Name == "HumanTeam" then --change this for human team
            plr.TeamColor ="White")
            cache[plr] = false

Try something like this. Put all of the team parts in the same folder, and name them to “HumanTeam” or “InfectedTeam”. Change the stuff that I outlined in the script to match the information that I did not have. If it doesn’t work, let me know

FYI This is all a server script, it doesn’t matter if you put it in workspace or serverscriptservice

wdym team parts? I’m just using the team folder thingy.

I mean the parts that change their team color when touched

bruh ur making this so confusing… but ill try…

It’s not, I’m just organizing it all into one script. I took the two you made and combined it into one. Something like this works better in a server script, and since this one requires a debounce, I used a “local debounce” in a cache table

btw I updated it

Okay I’m finna test this. real quick…

image ?

You have created a variable named team and assigned it to a BrickColor rather than a Team, you need to replace the line with a proper definition.

could u edit my script it do that, I don’t rlly understand sorry.:frowning:

The issue
You are trying to set the player’s team to a color, a color is not a team.
A team object is a team, hence the issue occurs.

The solution:
You’ll have to solve the issue by creating a team object in the Teams service and assigning the variable to it. I don’t know if there’s a better way to explain it sorry.

1 Like