Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Script in ServerScriptService
- local serverStorage = game:GetService("ServerStorage")
- local players = game:GetService("Players")
- local footballPrefab = serverStorage:WaitForChild("Football")
- local spawner = workspace:WaitForChild("FootballSpawner")
- local function giveTool(player)
- if player.Character then
- local tool = footballPrefab:Clone()
- tool.Parent = player.Backpack
- end
- end
- local function onTouched(hit)
- local character = hit.Parent
- local player = players:GetPlayerFromCharacter(character)
- if player then
- giveTool(player)
- end
- end
- spawner.Touched:Connect(onTouched)
- local function onFootballTouched(hit)
- local character = hit.Parent
- local player = players:GetPlayerFromCharacter(character)
- if player and not player.Backpack:FindFirstChild("Football") and not player.Character:FindFirstChild("Football") then
- local football = hit.Parent
- if football:IsA("Tool") and football.Name == "Football" then
- football.Parent = player.Backpack
- end
- end
- end
- workspace.ChildAdded:Connect(function(child)
- if child:IsA("Tool") and child.Name == "Football" then
- child.Handle.Touched:Connect(onFootballTouched)
- end
- end)
- -- ServerStorage > Tool > Script for Tool
- local tool = script.Parent
- local handle = tool:WaitForChild("Handle")
- local THROW_POWER = 50
- local MAX_THROW_DISTANCE = 100
- local function onActivated()
- local player = game.Players:GetPlayerFromCharacter(tool.Parent)
- if not player then return end
- local character = player.Character
- if not character then return end
- local humanoidRootPart = character:FindFirstChild("HumanoidRootPart")
- if not humanoidRootPart then return end
- local throwDirection = humanoidRootPart.CFrame.LookVector
- tool.Parent = workspace
- handle.CanCollide = true
- local bodyVelocity = Instance.new("BodyVelocity")
- bodyVelocity.Velocity = throwDirection * THROW_POWER
- bodyVelocity.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
- bodyVelocity.P = 1250
- bodyVelocity.Parent = handle
- game.Debris:AddItem(bodyVelocity, 0.1)
- wait(0.1)
- handle.CanCollide = true
- end
- tool.Activated:Connect(onActivated)
- -- Local Script for Tool
- local tool = script.Parent
- local players = game:GetService("Players")
- local userInputService = game:GetService("UserInputService")
- local function onEquipped()
- local player = players.LocalPlayer
- local character = player.Character
- if not character then return end
- local humanoid = character:FindFirstChildOfClass("Humanoid")
- if not humanoid then return end
- humanoid.WalkSpeed = 16
- end
- local function onUnequipped()
- local player = players.LocalPlayer
- local character = player.Character
- if not character then return end
- local humanoid = character:FindFirstChildOfClass("Humanoid")
- if not humanoid then return end
- humanoid.WalkSpeed = 16
- end
- tool.Equipped:Connect(onEquipped)
- tool.Unequipped:Connect(onUnequipped)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement