You don’t need to put the connection into a while loop you can connect it once.And use RemoteEvent:FireClient(player,args…).
Hit argument doesn’t returns a player character instead it returns the instance that touched it.To get a player character,you can use
local PlayerCharacter = hit:FindFirstAncestorOfClass(“Model”) – will return the first
parent which is a model
if not PlayerCharacter then return end – stop if no model instance found
then to get player
local Player = game.Players:GetPlayerFromCharacter(PlayerCharacter) – will get the player by char model
if not Player then return end – stop if model isnt a player char
This code will not work in the code the player has sent? If you check the code that @DanielosthebestYTAlt presented in this post, you can see that there is an if statement checking if the item which was hit is called “Ball” meaning that it is clearly not a player/character which is being touched.
My guess that this .Touched event is inside of the goal and when a goal happens they wish for all the clients to update the score (or at least that is what the code looks like). I don’t see why the user would even need to get the player if this is the use case of this code. Even if they needed the player who scored for like a notification system, the best way would probs to have a value in the ball which contains the last player who kicked it so that the code can detect who scored it rather then trying to get the player from the hit part which from my guess will never have a player unless it is due to a kick or something.
You are not firing the event to the correct player. game.Workspace.RedPoint:FireClient(hit)
hit is a part, which is not a player.
if hit.Parent is a player, then you could use: game.Workspace.RedPoint:FireClient(hit.Parent)