Hello, I am making a bossfight for my game and I want to make multiple attacks that spawn things where the player is so they have to well, move a bit. However the slight issue is I don’t know what I’m doing wrong in the script as the part’s position doesn’t change to the player’s position.
local TargetPart = game.Workspace:WaitForChild("HumanoidRootPart")
local XValue = TargetPart.Position.X
local ZValue = TargetPart.Position.Z
script.Parent.Position = Vector3.new(XValue, 3.25, ZValue)
I think you should do this in a LocalScript instead of a normal Script. And then type:
local player = game.Players.LocalPlayer
repeat wait(1) until player.Character ~= nil -- Waiting for player's character
local TargetPart = player.Character:WaitForChild("HumanoidRootPart")
local XValue = TargetPart.Position.X
local ZValue = TargetPart.Position.Z
script.Parent.Position = Vector3.new(XValue, 3.25, ZValue)
The entire script is incorrect, you need to find a way to grab the player that is in the “bossfight” and then use the players Character to get their HumanoidRootPart.