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)
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.
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)