Needing help with Serverstorage Cloning and Positioning

I am trying to figure out how to get a cloned object (cloned into workspace) to be at the exact position of another object, which moves to different positions. The code I’m working with is this:

I’ve tried multiple iterations all with unsatisfactory results. Please help.

1 Like
shot.Position = script.Parent.Head.Position

I’ve tried this. It doesn’t work. It only clones to its initial position, and not to the Head model’s position. It’s weird.

Is Head a model? Models don’t have a position property, so you’ll need to use a part in the model.
If not, does the output say anything?

1 Like

I worded it incorrectly. No, Head isn’t a model. It’s a part.

Alright good, just making sure.
Anything in the output?

I don’t see anything regarding it in the output. But I know it isn’t working because I can see the “shot” coming in from the wall of my arena instead of the “head” part of my boss entity. (I should’ve clarified this was for a boss entity, but doesn’t really matter regarding this error.)

Just making sure again, the boss moving and the bullet are both on the server right? That’s kind of all I can think of right now

I’m going to check this with one of my developer/friends and see if he can find out why it isn’t working. I’ll post it as the solution if one is found.

He’s unavailable. I don’t know what to do right now about this.

Just define the position as

local Pos = script.Parent.Head.Position
Shot.Position = Pos

Also Shot and Head must be parts not models

Neither of them are. They are parts.

Just FYI, it DOES clone into the workspace. However it isn’t cloning to the position shown. It just defaults to its initial position.

Is the head constantly moving? If so, Is the cloning frequent? If not, you need to updated the clone’s position frequently to the head’s position. You could use while for loops.


local ss = game:GetService("ServerStorage")
local PulsarShot = ss:WaitForChild("PulsarShot")
-- ^ defeined top of script
local shot = PulsarShot:Clone()
shot.Parent = workspace
shot.Position = script.Parent.Head.Position
shot.Ambience:Play()

Main issue is… script.Parent.Head
This isn’t yielding a position; it’s the part.
You want that part’s position.

It’s not exactly frequent. It’s part of a larger script that swaps between different attacks every 20 seconds.

Blockquote
local ss = game:GetService(“ServerStorage”)
local PulsarShot = ss:WaitForChild(“PulsarShot”)
local oldrandom = 0
local random = 0
repeat wait(20)
repeat
random = math.random(1, 3)
until random ~= oldrandom
oldrandom = random
if random == 1 then
script.Parent.Head.lasercharge:Play()
script.Parent.Head.lasercharge.Ended:Connect(function()
script.Parent.Head.LaserScriptt.Event:Fire()
end)
end
if random == 2 then
game.ReplicatedStorage.file:Fire()
end
if random == 3 then
local shot = PulsarShot:Clone()
shot.Parent = workspace
shot.Position = script.Parent.Head.Position
shot.Ambience:Play()
end
if script.Parent.Hum.Health < 1 then
script:Destroy()
end
until nil

This is the script currently from the help of other people. It still doesn’t seem to fix the issue. It’s not moving at the moment as I’m testing it in the boss’s dormant state. “if random ==3” is the one we are trying to fix.

Use the </> option on the bar to paste scripts in. It’s made for that. Paste between the … 's

Wait quick question, is the code moving your thing in a local script? This could be making its position stay still in the server but look like it’s moving for you in test.

I’m new to the dev forum, so I do not exactly know the whole thing yet. Sorry.

1 Like