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

how do i find out what the value of an intvalue is when someone touches a part?

i wanted to do this but i forgot that the intvalue wasnt in where the body parts are and i dont know how to find out the the intvalue of a player under game.players

script.Parent.Touched:connect(function(hit)
    if hit.Parent:FindFirstChild ("leaderstats") then
        if  hit.Parent:FindFirstChild ("leaderstats").Points.Value  >=  2 then
        print ("working")
        end
        end
end)


1 answer

The problem is, you're trying to get the leaderstats of a player from inside their character. That's not possible, as the leaderstats are in the player object, not the character. Instead, you should use GetPlayerFromCharacter() to find the Player from the character and get the leaderstats from the player. That probably doesn't make sense, so I added it to your script as an example.

script.Parent.Touched:connect(function(hit)
	if game.Players:GetPlayerFromCharacter(hit.Parent) then
		local Player = game.Players:GetPlayerFromCharacter(hit.Parent)
		if Player:FindFirstChild ("leaderstats") then
			if Player.leaderstats.Points.Value  >=  2 then
				print ("working")
			end
		end
	end
end)


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