Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How do I turn the LocalScript into Script?

This script makes the player change the body color of the player, when I tried on ServerClient, other players are not able to see the other player changing the body color, how do I fix this problem?

Here is the script:

local tool = script.Parent
local handle = tool.Handle

local eatSFX = handle.Eat

enabled = true

tool.Equipped:Connect(function()
	handle.BrickColor = BrickColor.Random()
end)

tool.Activated:Connect(function()
	if not enabled then return end

	enabled = false

	eatSFX:Play()
	tool.GripPos = Vector3.new(1.35, -1, -1)
	wait(2)
	tool.GripPos = Vector3.new(0, 0, 0)

	local players = game.Players.LocalPlayer
	local char = players.Character

	char.Head.BrickColor = BrickColor.Random()
	char.UpperTorso.BrickColor = BrickColor.Random()
	char.LowerTorso.BrickColor = BrickColor.Random()
	char["RightLowerArm"].BrickColor = BrickColor.Random()
	char["LeftLowerArm"].BrickColor = BrickColor.Random()
	char["RightUpperArm"].BrickColor = BrickColor.Random()
	char["LeftUpperArm"].BrickColor = BrickColor.Random()
	char["LeftLowerLeg"].BrickColor = BrickColor.Random()
	char["RightLowerLeg"].BrickColor = BrickColor.Random()
	char["RightUpperLeg"].BrickColor = BrickColor.Random()
	char["LeftUpperLeg"].BrickColor = BrickColor.Random()
	char["RightFoot"].BrickColor = BrickColor.Random()
	char["LeftFoot"].BrickColor = BrickColor.Random()
	char["RightHand"].BrickColor = BrickColor.Random()
	char["LeftHand"].BrickColor = BrickColor.Random()


	enabled = true
end)

1 answer

✓ Accepted answer

You can use the tool's parent, the character. Just change lines 22 and 23 from

local players = game.Players.LocalPlayer
local char = players.Character

to local char = tool.Parent

This just makes it possible to put it into a Script object so after editing your code put it into a Script object and delete the Local Script. This should make it load on all clients.

This gets the character. Hope this helped! Mark it as the answer if it solved your problem. Good Luck!

This discussion is preserved as it was. New answers, comments, and votes are closed.