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 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.)
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.
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.
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.