Soo, Basically everytime a player shoots with a basketball and is exactly 75 studs away from the basket/hoop/part then it should add 3 to the value.
local threepointer = 75 local goal = workspace.HoopOne for i,v in pairs(game.Players:GetChildren()) do if v.Character:FindFirstChild("Basketball") then ballposition = v.Character.Basketball.Handle.Position end end goal.Touched:Connect(function(hit) if hit.Parent == ("Basketball") then local player = game.Players:GetPlayerFromCharacter(hit.Parent) if (ballposition.Position -goal.Position).magnitude <= 75 then workspace.one.Value = workspace.one.Value + 3 end end end)
You're not comparing the correct data type.
Line 11, you want to compare hit.Parent (Which looks like its the character model) to string "Basketball". Instead do hit.Name.
goal.Touched:Connect(function(hit) if hit.Name == "Basketball" then local character = hit.Parent local hrp = character.HumanoidRootPart if (hrp.Position - goal.Position).magnitude >= 75 then workspace.one.Value = workspace.one.Value + 3 end end end)
edit: should be the distance between the player's current pos and the goal's pos
Full script:
local threepointer = 75 local goal = workspace.HoopOne --Use GetPlayers() to make sure you only get players for i,v in pairs(game.Players:GetPlayers()) do if v.Character:FindFirstChild("Basketball") then ballposition = v.Character.Basketball.Handle.Position end end goal.Touched:Connect(function(hit) if hit.Name == "Basketball" then local character = hit.Parent local hrp = character.HumanoidRootPart if (hrp.Position - goal.Position).magnitude >= threepointer then workspace.one.Value = workspace.one.Value + 3 end end end)