Or do you know where in the script the ball detects being kicked?
Player.Character["Left Leg"].Touched:connect(function(hit)
if TM.check() == "R" then return end
if hit.Name ~= "TPS" then return end
if Kick == false then return end
if workspace.Configuration.Curve.Value == true then return end
local force = Player.Character["Left Leg"].CFrame.lookVector * power
local angle = Vector3.new(10e+006, Angle, 10e+006)
Kick = false
TM.ApplyForce(hit, angle, force, "Left Leg", true)
if power >= 90 then
if hit.ReactDecline.Value == true and hit.Owner.Value ~= Player and workspace.Configuration.FirstTouch.Value == true then return end
local Spin = Instance.new("BodyAngularVelocity", hit)
Spin.AngularVelocity = Player.Character["Torso"].CFrame.rightVector * 25
Spin.MaxTorque = Vector3.new(math.huge, math.huge, math.huge)
game.Debris:AddItem(Spin, 0.5)
end
end)
I am sorry if this has bad math, I am pretty new to vector 3.
Use a remote event to send the player to a server script and from there store the player’s name in an attribute of the ball called something like “LastPlayerToTouch”
local event = ...
Player.Character["Left leg"].Touched:Connect(function(hit)
--code
TM.ApplyForce(...)
event:FireServer()
--code
end)
local event = ...
event.OnClientEvent:Connect(function(player)
local ball = ...
ball:SetAttribute("LastPlayerToKick", player.Name)
end)
When a goal is scored:
local playerWhoScored = ball:GetAttribute("LastPlayerToKick")
if playerWhoScored then
print(playerWhoScored, "has scored!") -- Change to show on gui / however you are doing it.
end
1 Like
It doesn’t work but it is fine, I will mark it as solution. Thanks for your help.
One last thing, would you know why this isn’t printing?
local ball = workspace.TPS --
game.Workspace.goal2.Touched:Connect(function(hit)
if hit.Parent == ball then
game.ReplicatedStorage.ScoreValue.Value = game.ReplicatedStorage.ScoreValue.Value +1
print("Goal! Team now has "..game.ReplicatedStorage.ScoreValue.Value.." goals.")
end
end)