Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Need help with getting humanoids name from part?

I'm trying to change a string value to the players name that touches a certain part?

(03:12:02.299 - Workspace.Arenas.Arena1.CoreParts.Pad1.Script:8: bad argument #3 to 'Value' (string expected, got Object))

script.Parent.Touched:connect(function(HumanPart)
	wait(0.1)
	local h = HumanPart.Parent:FindFirstChild("Humanoid")
	if h then
		if script.Parent.PlayerReady.Value == 1 then
			print("Player On")
			script.Parent.BrickColor = BrickColor.new("Bright red")
			script.Parent.PlayerNameOne.Value = h.Parent
			script.Parent.PlayerReady.Value = 2
		end
	end
end)

2 comments

0

If my answer helped then it would be great if you could upvote/accept it!

0

Won't line 4 pass as true even if h is nil? Don't you need if h~= nil then?

1 answer

I'm just going to ignore how your script violates so many practices, and just give you the answer:

on Line 08, change that to

script.Parent.PlayerNameOne.Value = h.Parent.Name

Because you're trying to set the value of something to an object when in reality it has to be the NAME of the object.

2 comments

0

Thanks man! Just realised how stupid I am.

0

Nah it's no problem- part of the learning process ya know?

This discussion is preserved as it was. New answers, comments, and votes are closed.