No, no, why are you trying to check if the HumanoidRootPart is a child of the player? It’s part of the character.
You get the error because LocalPlayer
is not a child nor a property of the service Players while you’re running it on the server.
Hmm @2147483647, try this instead [not fully aware on how to get a players model from workspace]:
local workspace = game:GetService("Workspace")
local TargetPart = workspace.LocalPlayer:WaitForChild("HumanoidRootPart")
local XValue = TargetPart.Position.X
local ZValue = TargetPart.Position.Z
script.Parent.Position = Vector3.new(XValue, 3.25, ZValue)
If this doesn’t work, try replacing what is currently stored in the workspace variable to simply game.Workspace.
… This won’t work either chief.
Is it the local workspace? Couldn’t remember if it’s a service or not.
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.
The script he attached was:
All I can think of is adding .LocalPlayer
next to game.Workspace
. @2147483647 please tell me if this works.
That doesn’t even make sense, if you don’t know how to script, please don’t confuse him more.
I do know how to script a little bit, I’m trying to help in the best possible way.
Doing what I usually do, i’ll try to help you.
First of all, I like to use CFrame and I’m not very good at Positions but ill try
I understand you are using a Localscript? Correct me if I’m wrong.
Currently, you do not have the player.
Get the player in a local script by doing the following:
local plr = game.Players.LocalPlayer`
This only works in a local script.
So if “HumanoidRootPart” is the players humanoid, then do the following
local plr = game:GetService("Players").LocalPlayer
local TargetPart = plr.Character:WaitForChild("HumanoidRootPart")
Now for the position, I HAVE NOT tried this myself, but I think it would work if you just change that in so the result would be:
local plr = game:GetService("Players").LocalPlayer
local TargetPart = plr.Character:WaitForChild("HumanoidRootPart")
local XValue = TargetPart.Position.X
local ZValue = TargetPart.Position.Z
script.Parent.Position = Vector3.new(XValue, 3.25, ZValue)
I’m still kind of confused on what you are trying to create with the script.Parent.Position but I’ve tried my best to help!
He’s trying to do this on the server, LocalPlayer doesn’t exist on the server…
@JustNode Informed me this was on the server.
See, you can have 2 options, one would be to do this when the player joins using the event “PlayerAdded” and the second one would be to make a way for this to activate, like clicking a button.
If you wish to use playeradded, use the following command and remember the first argument is the player-object
game.Players.PlayerAdded:Connect(function(plr)
local TargetPart = plr.Character:WaitForChild("HumanoidRootPart")
local XValue = TargetPart.Position.X
local ZValue = TargetPart.Position.Z
script.Parent.Position = Vector3.new(XValue, 3.25, ZValue)
end)
If you are choosing the activation method, you need a way to activate it, like a button. The example right now is a button, using a ClickDetector of course. You first need to find the ClickDetectors events, The event for a clicked button is “MouseClick” So it will look like this:
local button = path -- remove path and put in the path for the button. example: "game.Workspace.Button"
button.ClickDetector.MouseClick:Connect(function(plr) -- first argument is still the player-object
local TargetPart = plr.Character:WaitForChild("HumanoidRootPart")
local XValue = TargetPart.Position.X
local ZValue = TargetPart.Position.Z
script.Parent.Position = Vector3.new(XValue, 3.25, ZValue)
end)
First, this results in another error like this. Second, I need to make sure this works at a certain time frame since it’s well, a boss. The click detector script I don’t think would be useful for this situation.
If you want to do it at a certain frame, the thing I would do in that situation is to use PlayerAdded event and then go off of that, that way I’ll always have the player. And when It’s time, you execute the script. I’m unsure how else I can help you
Oh alright, I’ll see what I can do with that.
You can also use remotes to grab the player in an event.
Yes, that’s also a very good way to get the player once it’s required, totally flew by my mind.
Look, there’s another way to do this, you can make a RemoteEvent fires when you want the boss battle to be done.
And then do a for i, v loop taking all the players that are in the game. And then take their character. Like:
for i, v in pairs(game.Players:GetPlayers())
local character = v.Character
local TargetPart = character:WaitForChild("HumanoidRootPart")
local XValue = TargetPart.Position.X
local ZValue = TargetPart.Position.Z
script.Parent.Position = Vector3.new(XValue, 3.25, ZValue)
end
local players = game:GetService(“Players”)
repeat wait()
until players.LocalPlayer.Character
local TargetPart = players.LocalPlayer:WaitForChild(“HumanoidRootPart”)
local XValue = TargetPart.Position.X
local ZValue = TargetPart.Position.Z
script.Parent.Position = Vector3.new(XValue, 3.25, ZValue)
This’ll not work, normal scripts do not support LocalPlayer