I have a script where it detects after the ball hits the ground, it resets everyone and puts the ball at a certain spot, the spot is infront of the team's spawn. But there's 2 different spawns on each sides of the map, Lets say Team 1 threw it and it hits the ground, I'd want the ball to spawn at Team 2's spawn and vice versa. I'm stumped, thanks for looking this over.
script.Parent.Touched:connect(function(hit) if hit.Parent:findFirstChild("Football") then print("Reset") for i, player in ipairs(game.Players:GetPlayers()) do if player.Character then local hum = player.Character:FindFirstChild('Humanoid') if hum then wait(4) hum.Health = 0 player:LoadCharacter() local newItem = game.ReplicatedStorage.Football:Clone() newItem.Handle.CFrame = CFrame.new(-189.549, 1.55, -37.55) newItem.Parent = workspace end end end end end)
Thats the script so far, but I dont know how to detect who held it and what team they were on after it was thrown and hit the ground...
you can make a string value and set the value to the player that has the ball before its thrown, easy, because tools are directly in the chaarcter when held so you can jsut do script.Parent.Parent and i think thats the character of the tool, so when the ball is thrown, just check that value and you can know what the name of the player who threw the ball was :)
then just do
game.Players[PlayerName.Value].Character
and that will give you the actuall character instead of just the name, so then you can do whatever you want with him/her.
hope this helps :3
I'm pretty sure this doesn't work but I'm trying lol. Hope it helps
Players = game:GetService("Players") for i, player in pairs(Players:GetPlayers(player)) do local Tool = player.Backpack:FindFirstChild("ToolName") if Tool then -- insert your code here end end