How to make a part apper in top of a player

I’m making a fireball that appears on the player’s head, but I don’t know how to make the part appear on top of the player with CFrame, the part is in ReplicatedStorage

2 Likes

part.CFrame = Character.Head.CFrame*CFrame.new(0,1,0)

1 Like

the 1 can be adjusted according to the part size

1 Like

What @5pisak said is a good idea, but to add to that, I’d rather use HumanoidRootPart, because it is the only part of moving character that doesn’t shake while player is walking. Welding is probably even better, because it is significantly less performance demanding, compared to RunService looping.

Of course, do it server-side. Any part creation done client-side won’t replicate to others.

Hi! So you are trying to make a fireball appear on top of a character’s head. An easy way to do that is by making some variables then using the HumRootPart to spawn it.

Local rp = game:GetService("ReplicatedStorage")
Local HumRootPart = script.Parent -- assuming the script is in the character
Local Fireball = rp:WaitForChild("Fireball") -- This is supposed to be the name of your fireball
Local FireballC = Fireball:Clone()
FireballC.CFrame = HumRootPart.CFrame + Vector3.new(0, 5, 0)
wait(0.5)
FireBallC:Destroy()

--another alternative is 

Local rp = game:GetService("ReplicatedStorage")
Local HumRootPart = script.Parent -- assuming the script is in the character
Local Fireball = rp:WaitForChild("Fireball") -- This is supposed to be the name of your fireball
Local FireballC = Fireball:Clone()
FireballC.CFrame = HumRootPart.CFrame + Vector3.new(0, 5, 0)
Local Weld = Instance.new("WeldConstraint")
Weld.Part0 = FireBallC
Weld.Part1 = HumRootPart

I hope this helps!

I’m really sorry, but I beg to differ to about your post. If you save the script in The StarterPlayer.StarterCharacterScripts it will replicate to all characters.

Sorry for the silly question, but can this script be on ServerScriptService? is where my script will stay

Yes it can, but I will have to tweak it… Let me see

Local rp = game:GetService("ReplicatedStorage")
Local Fireball = rp:WaitForChild("Fireball") -- This is supposed to be the name of your fireball
function SpawnFire(player)
    player.CharacterAdded:Connect(function Char(Char))
        Local HumRootPart = Char:FindFirstChild("HumanoidRootPart") 
        Local FireballC = Fireball:Clone()
        FireballC.CFrame = HumRootPart.CFrame + Vector3.new(0, 5, 0)
        Local Weld = Instance.new("WeldConstraint")
        Weld.Part0 = FireBallC
        Weld.Part1 = HumRootPart
    end
end
game.Players.PlayerAdded:Connect(SpawnFire)

I hope this helps!!

‘(’ when parsing function, got ‘Char’

1 Like

I am so sorry. I forgot some stuff, here is the working version
local rp = game:GetService(“ReplicatedStorage”)
local Fireball = rp:WaitForChild(“Fireball”) – This is supposed to be the name of your fireball
function SpawnFire(player)
player.CharacterAdded:Connect(function(Character)
local HumRootPart = Character:FindFirstChild(“HumanoidRootPart”)
local FireballC = Fireball:Clone()
FireballC.CFrame = HumRootPart.CFrame + Vector3.new(0, 5, 0)
local Weld = Instance.new(“WeldConstraint”)
Weld.Part0 = FireballC
Weld.Part1 = HumRootPart
end)
end
game.Players.PlayerAdded:Connect(SpawnFire)

When I enter the game nothing happens, there is no error in the output

local rp = game:GetService("ReplicatedStorage")
local LightBomb = rp:WaitForChild("LightBomb") -- This is supposed to be the name of your fireball
function SpawnFire(player)
	player.CharacterAdded:Connect(function(Character)
		local HumRootPart = Character:FindFirstChild("HumanoidRootPart")
		local LightBombC = LightBomb:Clone()
		LightBombC.CFrame = HumRootPart.CFrame + Vector3.new(0, 5, 0)
		local Weld = Instance.new("WeldConstraint")
		Weld.Part0 = LightBombC
		Weld.Part1 = HumRootPart
	end)
end
game.Players.PlayerAdded:Connect(SpawnFire)

I am vey sorry for getting that wrong… I understand the problem now
local rp = game:GetService(“ReplicatedStorage”)
local Fireball = rp:WaitForChild(“Fireball”) – This is supposed to be the name of your fireball
function SpawnFire(player)
while true do
player.CharacterAdded:Connect(function(Character)
local HumRootPart = Character:FindFirstChild(“HumanoidRootPart”)
local FireballC = Fireball:Clone()
FireballC.Parent = workspace
FireballC.CFrame = HumRootPart.CFrame + Vector3.new(0, 7, 0)
local Weld = Instance.new(“WeldConstraint”)
Weld.Part0 = FireballC
Weld.Part1 = HumRootPart
end)
wait()
end
end
game.Players.PlayerAdded:Connect(SpawnFire)

That should at least make that part visible, I am working on the rest

@PatitoCeb unfortunately, that can’t be the case.There is almost no way for the client to create an instance like a part in Workspace in a way that is replicated to the server. As long as filtering is enabled, only certain exceptions are visible to the server: those are changes of player’s humanoid and its states, player sounds, player animations, and detections of ClickDetector. However, there are some rare exceptions when the BasePart is created by client and is replicated. That correlates with so called network ownership. Part’s physics are then simulated by a particular client, which means we’d have to give the client network ownership over the unanchored part. A very good example is an FPS system. When providing weapon equipping function, you have to be aware about the fact that none of what you do on the client is visible to “the rest of the world”. That’s why a remote signal is usually sent to the server, which then welds the given weapon to the player.

Please excuse me for late replying. Otherwise, I appreciate your posts!

ok i’m waiting, you may already know but when i enter the spawn fireball, but not spawn on top of the player, instead the spawn fireball away from the player

Eureka!! I found the answer here it is:

local rp = game:GetService(“ReplicatedStorage”)
function SpawnFire(player)
while true do
player.CharacterAdded:Connect(function(Character)
local Fireball = rp:WaitForChild(“Fireball”)
local HumRootPart = Character:FindFirstChild(“HumanoidRootPart”)
local FireballC = Fireball:Clone()
FireballC.Parent = workspace
local Head = HumRootPart.Parent.Head
FireballC.Position = Head.Position + Vector3.new(0, 7, 0)
local Weld = Instance.new(“WeldConstraint”)
FireballC.Anchored = false
Weld.Parent = FireballC
Weld.Part0 = FireballC
Weld.Part1 = HumRootPart
end)
wait()
end
end
game.Players.PlayerAdded:Connect(SpawnFire)

Please tell me if it worked for you :partying_face:

2 Likes

thank you it worked!

without wanting to be boring this is already very good but is there a way to do it without while?

1 Like

Actually, there is a way. Just erase the while

Alright, I here it is. This is still @PatitoCeb 's script, so they are the one who deserve the solution mark.

local ServerStorage = game:GetService("ServerStorage")
local lightBomb = ServerStorage.LightBomb

function SpawnFire(player)
	player.CharacterAdded:Connect(function(character)
		local humRootPart = character:FindFirstChild("HumanoidRootPart")
		
		local lightBombC = lightBomb:Clone()
		lightBombC.Position = humRootPart.Position + Vector3.new(0,7,0)
		lightBombC.Anchored = false; lightBombC.CanCollide = false
		lightBombC.Parent = character
		
		local weld = Instance.new("WeldConstraint") do
			weld.Part0 = lightBombC
			weld.Part1 = humRootPart
			weld.Parent = humRootPart
		end
	end)
end
game.Players.PlayerAdded:Connect(SpawnFire)

Parent was missing and unanchoring.

2 Likes

@PatitoCeb sorry but his script works better for what I intend to do but yours is great

@EssenceExplorer Ty.

1 Like

No problem, he deserves the credit then. I am happy you found a solution that is better. @EssenceExplorer, I am happy you helped

1 Like