You can write your topic however you want, but you need to answer these questions:
What do you want to achieve? When a player goales it should say “Somebody goaled”
What is the issue? it doesn’t change the text when its goaled
local ball = game.Workspace.Ball
local goal = game.Workspace.Part1
local function onCollisionEnter(part)
if part == goal then
game.StarterGui.ScreenGui.TextLabel.Text = "Goaled"
print("Goal!")
end
end
ball.Touched:Connect(onCollisionEnter)
You cannot change the text in a starterGui like that, you should fire a remote event and then change the text through a local script. By doing it this way you are changing the text on the server and not on the client.
It means that you’re actually changing the text that is in StarterGui. It is only replicated once (when the player joins/resets).
To fix this, you can either fire a RemoteEvent to change it from the client, or connect to the Players.PlayerAdded event, and then use the given Player object to change their UI individually from there.
game:GetService("Players").PlayerAdded:Connect(function(plr)
goal.Touched:Connect(function(otherPart)
if otherPart == ball then
plr.PlayerGui.ScreenGui.TextLabel.Text = "Goaled"
end
end)
end)