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

Why does this script appear to be working in Studio but not Roblox Player?

local Gate = game.Workspace.OwOMachine3000.Tunnel.Section3["3rdScanner"].LaserGate
local players = game:GetService("Players")

Gate.Touched:Connect(function(hit)
	if hit and hit.Parent:FindFirstChild("Humanoid") then
		local Char = hit.parent --this contains all the character limbs
		local Name = Char.Name
		local head = Char.Head
		local hair = Char["Brown Hair"]

		local plr = players[Name]
		print("plr")

		wait(5)

		for i,v in pairs(Char:GetChildren()) do
			if v:IsA("MeshPart") then
				
				v.Color = Color3.new(1, 1, 1)
				head.Color = Color3.new(1, 1, 1)
				hair.Parent = game.ServerStorage
				
			end
		end
	end	
end)

This is a script I've got that is supposed to change the colour of all the body parts and remove the hair when the Client touches a brick, it works perfectly in Studio and in a Local Server but when I play the game on Roblox it only changes the head colour and nothing else, and the hair stays on the character, does anyone know why this is?

7 comments

0

Is it a local script?

0

yeah

0

there's the problem

0

okay ill try a serverscript

0

Use a Remote event that fires a server event, and with a normal script, you do all the changes you want the rest of the players to see.

0

Use Event:FireServer(v)

0

wait what? so I need to make a serverscript that fires a remote event when the part is touched, then make a serverscript that has all of the above code in?

2 answers

✓ Accepted answer

Put this script into the LaserGate, You used a LocalScript on something that should be Serversided.

local Gate = script.Parent
local players = game:GetService("Players")
local SS = game:GetService("ServerStorage")

Gate.Touched:Connect(function(hit)
	if hit and hit.Parent:FindFirstChild("Humanoid") then
		local Char = hit.parent --this contains all the character limbs
		local Name = Char.Name
		local head = Char.Head
		local hair = Char["Brown Hair"]

		local plr = players[Name]
		print("plr")

		wait(5)

		for i,v in pairs(Char:GetChildren()) do
			if v:IsA("MeshPart") then

				v.Color = Color3.fromRGB(255,255,255)
				head.Color = Color3.fromRGB(255,255,255)
				hair.Parent = SS

			end
		end
	end 
end)
  1. You can get player with players:GetPlayerFromCharacter(Char)
  2. Not every player has brown hair unless you give it to them first(I assume you do)
  3. Change to:
for i,v in pairs(Char:GetChildren()) do
            if v:IsA("Part") then
                v.Color = Color3.new(1, 1, 1)
                hair.Parent = game.ServerStorage
            end
        end
  1. I don't remember if Color3 works on parts but if it doesn't then use BrickColor.new

2 comments

0

had to use brickcolor, but instead of working perfectly fine in studip, its only making the head white and removing the hair, and now in roblox player its doing nothing

0

Color3 does work on parts, BrickColor is just a simplified version of it that has Presets. (I suggest using Color3.fromRGB() instead of BrickColor)

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