✓ Accepted answer
Try this
script.Parent.Touched:connect(function(hit)
if game.Players:GetPlayerFromCharacter(hit.Parent) then
script.Parent.Parent.OwnerName.SurfaceGui.Owner.text = "Owned by: "..hit.Parent.Name
end
end)
Here we:
- Define the function in the event, to save space.
- Make the argument hit inside the function, with the Touched event the only argument is the thing that touched it.
- Check to make sure the parent of what touched it is a Player
- If the thing that touched it is a child of a Player, then it makes the text have that name in it
If this helped remember to make it the correct answer, thank you, and you're welcome. :)
3 comments
That worked perfectly except you had 1 capitalization issue. The 'text' in string 3 need's to be capitalized, just for future reference.
Capitalization error.. line 3
Sorry about that, everything else was fine so that's cool.