so i have this problem where the .Touched event runs as soon as i press play, instead of waiting for the ball to touch it first. here's my script: (ignore the game.Workspace... twice, i had a bug where if i made it local something it would just affect the player instead)
local part = script.Parent part.Touched:Connect(function(hit) local ball = hit.Parent:FindFirstChild("Ball") if ball then game.Workspace.Ball.Anchored = true game.Workspace.Ball.BrickColor = BrickColor.new("Gold") end end)
Well, according to your code, if any basic part or meshpart [which is not inside a model and in workspace], will trigger your .Touched
event.
In order to fix, try the following code:
local part = script.Parent part.Touched:Connect(function(hit) local ball = hit.Name -- Gets the name of the hitting part if ball == "Ball" then -- Checks if the name is Ball game.Workspace.Ball.Anchored = true game.Workspace.Ball.BrickColor = BrickColor.new("Gold") end end)
Lemme know if it helps!