Script not working as itended

I have this script here which changes the startercharcacter when they say a certain word but it changes everyone’s startercharacter, when I just want it to change the person who said the words startercharcater. Here is the script:

local Players = game:GetService("Players")

local player = Players.LocalPlayer



local davidvenin2015Variable = game.Lighting.davidvenin2015
local NormalStarterCharacter = game.StarterPlayer.StarterCharacter



game.Players.PlayerAdded:Connect(function(player) -- runs every time a player joins
	player.Chatted:Connect(function(msg) -- runs once the player that joined chats a message
		if msg == "davidvenin2015" then -- create your conditions
			davidvenin2015Variable.Name = "StarterCharacter"
			NormalStarterCharacter.Name = "NormalCharacter"
			davidvenin2015Variable.Parent = game.StarterPlayer
			NormalStarterCharacter.Parent = game.Lighting
			player:LoadCharacter()
		end
	end)
end)
local Players = game:GetService("Players")
local player = Players.LocalPlayer
local davidvenin2015Variable = game.Lighting.davidvenin2015
local NormalStarterCharacter = game.StarterPlayer.StarterCharacter

	player.Chatted:Connect(function(msg) 
		if msg == "davidvenin2015" then -- create your conditions
			davidvenin2015Variable.Name = "StarterCharacter"
			NormalStarterCharacter.Name = "NormalCharacter"
			davidvenin2015Variable.Parent = game.StarterPlayer
			NormalStarterCharacter.Parent = game.Lighting
			player:LoadCharacter()
		end
	end)

Just put this script in a local script!

Do I put it in serverscriptservice?

No in a local script for example in starter player scripts. Because it is a local script you dont have to add the player added function!

It doesn’t change the startercharacter for some reason.

Can you show us the Variable youve put in Lighting?

Players.LocalPlayer is for the client ONLY. The server is not a player, so it returns as nil and breaks. Please read this: Roblox Client-Server Model . The script will work if its local to the player (meaning you put it in one of the following services/objects: A tool, StarterPlayerScripts, StarterCharacterScripts, StarterPack, StarterGui.

1 Like

Put that in ServerStorage and Rename it as StarterCharacter

If you would like to do this on the server, do this instead:

local Players = game:GetService("Players")

local davidvenin2015Variable = game:GetService("Lighting"):WaitForChild("davidvenin2015")
local NormalStarterCharacter = game:GetService("StarterPlayer"):WaitForChild("StarterCharacter")

Players.PlayerAdded:Connect(function(player) -- runs every time a player joins
	player.Chatted:Connect(function(msg) -- runs once the player that joined chats a message
		if msg == "davidvenin2015" then -- create your conditions
			davidvenin2015Variable.Name = "StarterCharacter"
			NormalStarterCharacter.Name = "NormalCharacter"
			davidvenin2015Variable.Parent = game:GetService("StarterPlayer")
			NormalStarterCharacter.Parent = game:GetService("Lighting")
			player:LoadCharacter()
		end
	end)
end)

Sorry, but isnt that the same script as he mentioned in his first post?

1 Like

Yes, but I fixed some syntax and added the appropriate code for the server.

1 Like

That still doesn’t work for some reason.