local tool = script.Parent
local plr -- Wondering why I used a line which is not even defined ? Let's find it.
local ClonedTool = game.ReplicatedStorage.PaperAirplane:Clone()
tool.Bounce.OnServerEvent:Connect(function(player, event)
plr = player --Basically, we did a smart trick. We defined a variable plr which is nil. But if you don't know, we can easily assign player object to this variable and now the value of the variable is setted to player object. Now you can just call this variable as player!
print(player)
local mouse = player:GetMouse()
local ball = tool.Handle
tool.Parent = workspace
ball.CFrame = tool.Handle.CFrame
ball.CFrame = CFrame.new(ball.Position, event)
local BV = Instance.new("BodyVelocity", ball);
BV.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
BV.Velocity = ball.CFrame.lookVector * 50 -- how fast it throws
wait(.1)
tool.Handle.BodyVelocity:Destroy()
end)
local isTouched=false
local Handle = script.Parent.Handle
script.Parent.Handle.Touched:Connect(function(hit)
print("hit")
if hit.Parent:FindFirstChild("Part") then
print("Is part")
wait(2)
script.Parent:Destroy()
local ClonedTool = game.ReplicatedStorage.PaperAirplane:Clone()
ClonedTool.Parent = plr.Backpack
print("Destroyed")
end
end)
Sorry for bothering you, but do you know how to add Coins to the player once the airplane is destroyed?
ive already got a leaderstats script but Im having trouble giving coins.
local tool = script.Parent
local plr -- Wondering why I used a line which is not even defined ? Let's find it.
local ClonedTool = game.ReplicatedStorage.PaperAirplane:Clone()
tool.Bounce.OnServerEvent:Connect(function(player, event)
plr = player --Basically, we did a smart trick. We defined a variable plr which is nil. But if you don't know, we can easily assign player object to this variable and now the value of the variable is setted to player object. Now you can just call this variable as player!
print(player)
local mouse = player:GetMouse()
local ball = tool.Handle
tool.Parent = workspace
ball.CFrame = tool.Handle.CFrame
ball.CFrame = CFrame.new(ball.Position, event)
local BV = Instance.new("BodyVelocity", ball);
BV.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
BV.Velocity = ball.CFrame.lookVector * 50 -- how fast it throws
wait(.1)
tool.Handle.BodyVelocity:Destroy()
end)
local isTouched=false
local Handle = script.Parent.Handle
script.Parent.Handle.Touched:Connect(function(hit)
print("hit")
if hit.Parent:FindFirstChild("Part") then
print("Is part")
wait(2)
script.Parent:Destroy()
local ClonedTool = game.ReplicatedStorage.PaperAirplane:Clone()
ClonedTool.Parent = plr.Backpack
print("Destroyed")
plr.leaderstats.Something.Value += value you want
end
end)