How to make a part apper in top of a player

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

First of all, I didn’t really add anything special. Instance location, parent and HumanoidRootPart… I still think you deserve credit, because you were the first who actually provided code. Yet, at the end of the day, it’s not really important, seeing the problem is solved (this can now be used in any way we can think of, as a tool, part can be also activated using UserInputService etc.).
Good luck with your projects @PatitoCeb and @RVTGAMERGg ! :smiley:

May I know why you didn’t use manual welds instead?

1 Like

Do you mean Welds? Because WeldConstraints are (as the Roblox Dev Hub currently says) the newer alternative to classical Welds. They were used by @PatitoCeb before me and are actually useful, because they don’t have C0 and C1 offset properties, which is an advantage, but also a disadvantage sometimes, depending on the needs of course.

1 Like

Actually, you can make a part that replicates (as long as it’s not anchored) by giving the client network ownership.

1 Like

Yes, I think I mentioned that, but thanks for pointing it out. That needs to be done with special care, because unanchored parts in client’s network ownership are often subjects to exploits. Giving the client network ownership over a part also means giving him/her the power to simulate its physics.