Hi! I am trying to find out how to find a model(s) in Workspace with a script.

Basically, I am trying to anchor a custom character that values to the player by changing its name to the player's name.

Code:

wait(10)
local Teams = game:GetService("Teams")
local SpawnTeam = Teams.Spawn
local Playing = Teams.Spawn
local MainFrame = script.Parent.Parent.MainFrame
local player = game.Players.LocalPlayer
local Player = game.Workspace.player
local Leg1 = Player.RightLeg
local Leg2 = Player.LeftLeg

if MainFrame.Visible == true then
	player.Team = SpawnTeam
	player.TeamColor = SpawnTeam.TeamColor
	
	Leg1.Anchored = true
	Leg2.Anchored = true
	
end

I know you cant use-value LocalPlayer in Workspace but I was trying something there. If your confused maybe you can find out what I mean in the code.

I had a few solutions in mind I just don't know how to do them. The best one I think I have is that I add a value to the StarterCharacter Model in the StarterPlayer folder that is found by a script and tells the player apart from the other models to make it easier for the anchor script to find the player models. I just don't know how to code that. If you aren't catching me here I mean since there will be multiple people joining I can not just put my name like the following:

wait(10)
local Teams = game:GetService("Teams")
local SpawnTeam = Teams.Spawn
local Playing = Teams.Spawn
local MainFrame = script.Parent.Parent.MainFrame
local player = game.Players.LocalPlayer
**local Player = game.Workspace.UnknownUne**
local Leg1 = Player.RightLeg
local Leg2 = Player.LeftLeg

if MainFrame.Visible == true then
	player.Team = SpawnTeam
	player.TeamColor = SpawnTeam.TeamColor
	
	Leg1.Anchored = true
	Leg2.Anchored = true
	
end

I can't do that because for other users it will have their name. And since I can not do a LocalPlayer with workspace (unless you can and I am just doing it wrong) that means I have to find another way to tell the model apart from all the other models and other player models.

My other solution was that I find a way in the localscript to have localplayer print the name in the script so it will automatically go to local Player = game.Workspace.(name_of_model/player). I feel like this wouldn't work though since simply putting LocalPlayer there did not work.

Sorry if I confused you there. I hope anyone can understand this and help me. I will check the comments tomorrow morning. Thank you guys!

6 comments

0

sorry If i confused anyone there

0

Hello, what exactly are you trying to do?

0

You shouldn't share you're entire code, only share the part that is actually relevant.

0

Use player.Name to find the player in workspace

0

Thanks Razzy! I will try it now. kingblaze_1000 I thought it would all be relevant. there is still a bit more.

0

RazzyPlayz It does not work. Code: