So I have this script that gives a player 1 point whenever they score a goal, but it isn’t working. When I looked in the output I saw no errors.
Here is the script:
local teams = game:GetService("Teams")
local goal1 = game:GetService("Workspace").Map.goal2
local goal2 = game:GetService("Workspace").Map.goal1
local ball = game:GetService("Workspace"):WaitForChild("TPS")
local rs = game:GetService("ReplicatedStorage")
local me = rs:WaitForChild("Message")
local Kick = true
function onGoal()
ball.Touched:Connect(function(part)
if part == goal1 == true and teams.Bayern and teams.GKB == false then
local Scorer = game:GetService("Workspace"):WaitForChild("TPS").Owner.Value
local Scorer_Name = Scorer.Name
local Message = string.upper(Scorer_Name).." SCORED!"
me:FireAllClients(Message)
Scorer.leaderstats.Goals.Value = Scorer.leaderstats.Goals.Value +1
task.wait(12)
Kick = false
elseif part == goal2 == true and teams.Milan and teams.GKM == false then
local Scorer = game:GetService("Workspace"):WaitForChild("TPS").Owner.Value
local Scorer_Name = Scorer.Name
local Message = string.upper(Scorer_Name).." SCORED!"
me:FireAllClients(Message)
Scorer.leaderstats.Goals.Value = Scorer.leaderstats.Goals.Value +1
task.wait(12)
Kick = false
end
end)
end
local teams = game:GetService("Teams")
local goal1 = game:GetService("Workspace").Map.goal2
local goal2 = game:GetService("Workspace").Map.goal1
local ball = game:GetService("Workspace"):WaitForChild("TPS")
local rs = game:GetService("ReplicatedStorage")
local me = rs:WaitForChild("Message")
local Kick = true
ball.Touched:Connect(function(part)
if part == goal1 and teams.Bayern and teams.GKB == false then
local Scorer = game:GetService("Workspace"):WaitForChild("TPS").Owner.Value
local Scorer_Name = Scorer.Name
local Message = string.upper(Scorer_Name).." SCORED!"
me:FireAllClients(Message)
Scorer.leaderstats.Goals.Value = Scorer.leaderstats.Goals.Value +1
task.wait(12)
Kick = false
elseif part == goal2 and teams.Milan and teams.GKM == false then
local Scorer = game:GetService("Workspace"):WaitForChild("TPS").Owner.Value
local Scorer_Name = Scorer.Name
local Message = string.upper(Scorer_Name).." SCORED!"
me:FireAllClients(Message)
Scorer.leaderstats.Goals.Value = Scorer.leaderstats.Goals.Value +1
task.wait(12)
Kick = false
end
end)
ur Touched function was inside another function which was never fired so i took it out. now the code is running and thats why u even can see the errors now
No, I am using another script for that. Here is the script:
local RS = game:GetService("ReplicatedStorage")
local Event = RS:WaitForChild("ChangeOwner")
local Event2 = RS:WaitForChild("ChangeValue")
Event.OnServerEvent:connect(function(player, ball)
local Distance = player.Character.HumanoidRootPart.Position.Magnitude - ball.Position.Magnitude
if ball.Name ~= "TPS" then return end
if game:GetService("Workspace"):WaitForChild("TPS" , math.huge).Anchored == true then return end
if Distance > 10 then return end
if ball.Owner.Value ~= player then
ball:SetNetworkOwner(player)
ball.Owner.Value = player
ball.ReactDecline.Value = true
local Bubble = Instance.new("Part")
Bubble.Shape = "Ball"
Bubble.Position = ball.Position
Bubble.Name = "ReactBubble"
Bubble.CanCollide = false
Bubble.Anchored = true
Bubble.Transparency = 0.849
Bubble.BrickColor = BrickColor.new("Really black")
Bubble.BrickColor = player.TeamColor
Bubble.Size = Vector3.new(2,2,2)
Bubble.Parent = workspace
wait(0.8)
ball.ReactDecline.Value = false
Bubble:Destroy()
end
end)
Event2.OnServerEvent:connect(function(player, ball)
if game:GetService("Workspace"):WaitForChild("TPS" , math.huge).Anchored == true then return end
ball.Ankle.Value = true
wait(0.5)
ball.Ankle.Value = false
end)
if game:GetService("Workspace"):WaitForChild("TPS" , math.huge).Anchored == true then return end