Hi I am Making an Attribute in a Ball thats text is whoever touched it but it dont seem to work
ball = script.Parent
local att = ball:GetAttribute("LastTouch")
ball.Touched:Connect(function(hit)
if hit.Parent:FindFirstChildOfClass("Humanoid") then
att = hit.Parent.Name
end
end)
Hi, what’s happening is your att variable is set to the lastTouch attribute (which I’m assuming is nil by runtime). Then, once the ball is touched, you set that att variable to hit.Parent.Name. You didn’t change the attribute value, but you just changed what the att variable refers to (first, it refers to LastTouch attribute, then it refers to hit.Parent.Name).
If you wish to actually set the value of the LastTouch attribute, you would write the following:
ball:SetAttribute("LastTouch", hit.Parent.Name)
instead of
att = hit.parent.Name
You also will not have a need for the att variable