Hey there Curry lol.
This is one of my first time seeing a question like this, so I thought I'd give it a try!
WARNING : This will be a looong guide to follow, so be patient!
I dont play basketball on roblox but I am sure I can figure out how the scripts function.
I will guide you step by step on what to do.
First thing you're going to want to do is Workspace > Insert Tool.
Then Tool > Insert Part.
Rename that Part as "Handle".
Now were going to start with the Handle first; we are going to need to insert a few things.
1 . Workspace > Insert Sound [Insert this into ID : rbxasset://sounds//short spring sound.wav]
2 . Workspace > Insert Mesh [Insert this ID to the end of the TextureID : 192001003]
3 . Workspace > Insert TouchInterest
4 . Workspace > Insert Script
In that Script insert this code :
Basketball = script.Parent
function onTouched(hit)
script.Parent.Parent.Movement.Disabled = false
script.Parent.Parent.Other.Disabled = true
end
connection = Basketball.Touched:connect(onTouched)
After you have finished the Handle, we can now begin to insert our Scripts.
The first one we will do is the Shooting one.
Start off with Tool > Insert Script
Then rename that Script as "CannonBall"
Inside of CannonBall insert this coding :
ball = script.Parent
damage = 10
r = game:service("RunService")
last_sound_time = r.Stepped:wait()
function onTouched(hit)
local now = r.Stepped:wait()
if (now - last_sound_time > .1) then
ball.Boing:play()
last_sound_time = now
else
return
end
local humanoid = hit.Parent:findFirstChild("Humanoid")
local zombie = hit.Parent:findFirstChild("Zombie")
if humanoid~=nil then
tagHumanoid(humanoid)
humanoid.Health = humanoid.Health - damage
wait(2)
untagHumanoid(humanoid)
connection:disconnect()
else
damage = damage / 5
if damage < 2 then
connection:disconnect()
end
end
end
function tagHumanoid(humanoid)
local tag = ball:findFirstChild("creator")
if tag ~= nil then
local new_tag = tag:clone()
new_tag.Parent = humanoid
end
end
function tagZombie(zombie)
local tag = ball:findFirstChild("creator")
if tag ~= nil then
local new_tag = tag:clone()
new_tag.Parent = zombie
end
end
function untagHumanoid(humanoid)
if humanoid ~= nil then
local tag = humanoid:findFirstChild("creator")
if tag ~= nil then
tag.Parent = nil
end
end
end
connection = ball.Touched:connect(onTouched)
t, s = r.Stepped:wait()
d = t + 5.0 - s
while t < d do
t = r.Stepped:wait()
end
ball.Parent = nil
After that, lets add another; Tool > Insert Script
Rename this Script to "CannonScript"
Insert this coding :
Tool = script.Parent
function fire(v)
Tool.Handle.Boing:play()
local vCharacter = Tool.Parent
local vPlayer = game.Players:playerFromCharacter(vCharacter)
local spawnPos = vCharacter.PrimaryPart.Position
spawnPos = spawnPos + (v * 5)
connection:disconnect()
wait()
Tool.Parent = game.Workspace
Tool.Handle.Position = spawnPos
Tool.Handle.Velocity = v * 100
Tool.Movement.Disabled = false
Tool.Other.Disabled = true
end
function onActivated()
local character = Tool.Parent;
local humanoid = character.Humanoid
if humanoid == nil then
print("Humanoid not found")
return
end
local targetPos = humanoid.TargetPoint
local lookAt = (targetPos - character.Head.Position).unit
fire(lookAt)
end
while true do
script.Parent.Activated:wait()
connection = game:service("RunService").Stepped:connect(onActivated)
wait(2)
end
Once you have completed that, lets move on to Script #3.
Tool > Insert Script ; Rename this Script to "LoseBall"
Insert this coding :
while true do
wait()
if script.Parent.Parent ~= game.Workspace and script.Parent.Parent.Humanoid ~= nil and script.Parent.Parent.Humanoid.Sit ~= false then
script.Parent.Parent = game.Workspace
script.Parent.Handle.CFrame = script.Parent.Handle.CFrame + Vector3.new(math.random(1,2),4,math.random(1,2))
end
end
Once you have done that, insert another.
Tool > Script ; Rename it to "Movement"
Insert this :
while true do
script.Parent.GripPos = Vector3.new(0, 0.5, 0)
wait(0.1)
script.Parent.GripPos = Vector3.new(0, 1, 0)
wait(0.05)
script.Parent.GripPos = Vector3.new(0, 1.5, 0)
wait(0.05)
script.Parent.GripPos = Vector3.new(0, 2, 0)
wait(0.05)
script.Parent.GripPos = Vector3.new(0, 2.5, 0)
wait(0.05)
script.Parent.GripPos = Vector3.new(0, 3, 0)
wait(0.1)
script.Parent.GripPos = Vector3.new(0, 2.5, 0)
wait(0.05)
script.Parent.GripPos = Vector3.new(0, 2, 0)
wait(0.05)
script.Parent.GripPos = Vector3.new(0, 1.5, 0)
wait(0.05)
script.Parent.GripPos = Vector3.new(0, 1, 0)
wait(0.05)
end
We are almost done! Dont worry lol,
Tool > Insert Script ; Rename this script to "NoHide"
Insert this :
while true do
wait()
if script.Parent.Parent.Name == "Backpack" then
script.Parent.Parent = script.Parent.Parent.Parent.Character
end
end
Another ; Tool > Insert Script
Rename it to "Other"
Insert this :
do
script.Parent.GripPos = Vector3.new(0.2, 0, 0.6)
end
Another Script ; Tool > Insert Script
Rename this one to "Steal"
Insert this :
script.Parent.Handle.Touched:connect(function(hit)
pcall(function()
player = game.Players:getPlayerFromCharacter(hit.Parent)
script.Parent:Clone().Parent = player.Backpack
script.Parent:Remove()
end)
end)
NOW! Were done inserting our Scripts, now its time to begin our LocalScripts.
Tool > LocalScript ; Rename it to "LocalGUI".
Insert this into that Script :
local Tool = script.Parent;
enabled = true
function onButton1Down(mouse)
if not enabled then
return
end
enabled = false
mouse.Icon = "rbxasset://textures\\GunWaitCursor.png"
wait(2)
mouse.Icon = "rbxasset://textures\\GunCursor.png"
enabled = true
end
function onEquippedLocal(mouse)
if mouse == nil then
print("Mouse not found")
return
end
mouse.Icon = "rbxasset://textures\\GunCursor.png"
mouse.Button1Down:connect(function() onButton1Down(mouse) end)
end
Tool.Equipped:connect(onEquippedLocal)
One more LocalScript! Tool > Insert LocalScript
Rename this one to "LocalScript"
Insert this :
Tool = script.Parent
function onKeyDown(key)
local Player = game.Players:GetPlayerFromCharacter(script.Parent.Parent)
key = key:lower()
if key == " " then
script.Parent.Movement.Disabled = true
script.Parent.Other.Disabled = false
end
if key == "f" then
script.Parent.Movement.Disabled = false
script.Parent.Other.Disabled = true
end
end
function onEquipped(mouse)
mouse.KeyDown:connect(onKeyDown)
end
script.Parent.Equipped:connect(onEquipped)
Now, our Basketball is 100% complete! Wow, that was a lot of coding lol.
Just insert this into Lighting or StarterPack to use it.
PM me if you have any problems! (:
2 comments
WOAH! Thanks alot dude! I wasnt even expecting anyone to take my request serious because I play basketball, thanks!!
Your very welcome, glad I could help (: