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 get this avatar customizer to work?

local Plr = game:GetService("Players").LocalPlayer
local Button = script.Parent
local RS = game:GetService("ReplicatedStorage")
local Halo = RS.Halos:WaitForChild("Halo")
Button.MouseButton1Click:Connect(function()
	local ClonedHalo = Halo:Clone()
	ClonedHalo.BrickColor = BrickColor.new("Bright blue")
	ClonedHalo.Material = Enum.Material.Neon
	ClonedHalo.Parent = Plr
	ClonedHalo.Position = Vector3.new(Plr.Character.HumanoidRootPart.Position + Vector3.new(0,5,0))
end)

What I want to happen is the Halo spawns above the players head and doesnt fall or anything, moves when they move.

1 answer

✓ Accepted answer

You are putting the piece inside the player. Try it inside the player's character.

LocalScript

local RS = game:GetService("ReplicatedStorage")
local Player = game.Players.LocalPlayer

script.Parent.MouseButton1Click:Connect(function()
	local Halo = RS:WaitForChild("Halos"):WaitForChild("Halo"):Clone()
	local Character = Player.Character

	Halo.Parent = Character
	Halo.Position = Character.Head.Position + Vector3.new(0,5,0)
	local Character = Player.Character
end)

However, the piece will be visible only to the player, not to the other players on the server, because it is a function in a LocalScript. Use a remoteEvent in RS, and a Script in SSS, so that all players can see the piece.

LocalScript

local RS = game:GetService("ReplicatedStorage")
local RemoteEvent = RS:WaitForChild("RemoteEvent")

script.Parent.MouseButton1Click:Connect(function()
	RemoteEvent:FireServer()
end)

Script in ServerScriptService

local RS = game:GetService("ReplicatedStorage")
local RemoteEvent = RS:WaitForChild("RemoteEvent")

RemoteEvent.OnServerEvent:Connect(function(Player)
	local Halo = RS:WaitForChild("Halos"):WaitForChild("Halo"):Clone()
	local Character = Player.Character

	Halo.Parent = Character
	Halo.Position = Character.Head.Position + Vector3.new(0,5,0)
end)

I hope I helped, if it goes wrong, could you tell me what broke the Script? That way I can help fix it. :)

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