How would i get a string that is going to be altered?

so i made a ragdoll system, and i am gonna name the ragdoll like this:

	ragdoll.Name = ""..char.Name.."1"

no problem right, but when i want to get the ragdoll’s position from the server, i am a little bit stomped.
i tried to to this but it tried to find “ames” which is a varible

	local ame = ""..char.Name.."1"
			local clone = game.ReplicatedStorage.Drop:Clone()
			clone.Parent = game.Workspace
			clone.Position = game.Workspace.ame.Head.Position
1 Like

You’re trying to use the variable to dot index the workspace so yes it’d try to find “ame” instead. You want this to evaluate to whatever the ame variable is pointing to instead - use square brackets to index the workspace instead so it resolves to the value of ame.

game.Workspace[ame].Head.Position

I don’t really support indexing workspace by certain names like this, I think you should just have the model reference on hand somewhere, but that’s a story for another time irrelevant to this scenario. Don’t have enough context to go at lengths about good practice as a side note.

1 Like

wait, it said this:

 19:57:53.572  foxnoobkite1 is not a valid member of Workspace "Workspace"

That’s not enough context for me to understand your problem. I could think of a number of issues as to why you’d get an error for this, such as a race condition (whatever code is here is running before the name script runs) or the model doesn’t actually exist. Those are things you need to debug your code for. If you’re looking for help from others, you need to provide detailed context – screenshots would additionally help. Just reading an error isn’t enough.

1 Like

well the rest of the script isn’t that intresting

game.Players.PlayerAdded:Connect(function(plr)
	plr.CharacterAdded:Connect(function(char)
		char:WaitForChild("Humanoid").Died:Connect(function()
			wait(0.1)
			local clone = game.ReplicatedStorage.Drop:Clone()
			clone.Parent = game.Workspace
			clone.Position = game.Workspace[""..char.Name.."1"].Head.Position
			clone.Bounty.Value = plr.Leaders.Bounty.Value
			clone.Ignore = plr.Name
			wait(0.1)
			plr.Resources.Bounty.Value = 0
		end)
	end)
end)

its just some mumbo jumbo about adding a death drop system

i tried make it wait 0.1 seconds so the ragdoll can catch up and make the model before it finds it

WaitForChild since it seems like you’ve divorced the model parenting logic from this.

clone.Position = workspace:WaitForChild(char.Name .. "1").Head.Position

Adding an arbitrary wait won’t resolve your problem in the best manner.

1 Like

hmm same result,

Infinite yield possible on 'Workspace:WaitForChild("foxnoobkite1")

i think theres something wrong with the ragdoll side maybe? i set the name to:

ragdoll.Name = ""..char.Name.."1"

yeah i don’t think its the ragdoll side problem since i checked workspace and it worked fine