Answered by
3 years ago Edited 3 years ago
Touched event returns for the touched part. They does not return the character name, but the body part touched. So to locate the Character in a Touched event, do local character = hit.Parent
.
Also you did a little mistake. Since sometimes some other parts like Baseplate will also touch the part, which also fires the event and returns an error "Workspace is not a Player" or something like that. You can detect if it have a humanoid, if not, return the function.
Lastly, your debounce script also have mistake. You can still bypass the debounce by making it true and false. What are you going to do is make a if-statement, if the debounce is true, then make it pass. Else don't!
I've set up the script for you. If you have any problems, comment below so I will get the notification
Script:
03 | script.Parent.Touched:Connect( function (hit) |
04 | if debounce = = true and hit.Parent:FindFirstChild( "Humanoid" ) then |
06 | local character = hit.Parent |
07 | local player = game:GetService( "Players" ):GetPlayerFromCharacter(character) |
08 | if player and player.leaderstats.Tix.Value > = 9000 then |
09 | print (player.Name .. " Tix value is 9000 or more than 9000!" ) |