Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How can I correct this team changing script because it dosen't work?

Asked by 4 years ago

I was trying to script some team changing though once I thought I finished it didn't work like it did before. Here is my scripting on both scripts:

-- Team change script -- Add our teams

local RemoteEvent = game:ReplicatedStorage.Teamchange

local menuButton

local frame = script.Parent:WaitForChild("Frame")

-- TEAM COLOURS

local Visitor/GuestColor = "Fossil" local FactoryWorkerColor = "Neon orange"

frame.Visitor/Guest.MouseButton1Click:Connect(function() RemoteEvent:FireServer(BrickColor.new(Visitor/GuestColor)) end)

frame.FactoryWorker.MouseButton1Click:Connect(function() RemoteEvent:FireServer(BrickColor.new(FactoryWorkerColor)) end)

That was my first script. Now my second:

-- Handle the remote event

game.ReplicatedStorage.Teamchange.OnServerEvent:Connect (function(player,teamColor) player.TeamColor = teamColor player:LoadCharacter() end)

1 answer

Log in to vote
0
Answered by
compUcomp 417 Moderation Voter
4 years ago

There are a few problems here. Variable names must be composed of alphanumeric characters and underscores, so "Visitor/GuestColor" is not a valid name. Omit the slash. When accessing children of ReplicatedStorage from the client, you should use WaitForChild. So this line: local RemoteEvent = game:ReplicatedStorage.Teamchange Should become: local RemoteEvent = game.ReplicatedStorage:WaitForChild("Teamchange") Also, the syntax was wrong. When accessing a service, either use dot notation or game:GetService.

Ad

Answer this question