I have a system here, where if the slected number is one, we give the player a tool from replicated sorage to there “Backpack”, but it doesnt seem to work.
function onTouched(hit)
if hit.Parent:findFirstChild("Humanoid") then
print("Hit")
print(ToolNumber1)
if ToolNumber1 == 1 then
print("Tool 1 Was Given To The Player ")
if ToolNumber1 == 1 then
local Sword = game.ReplicatedStorage.Tools:WaitForChild("ClassicSword")
function onTouched(hit)
if hit.Parent:findFirstChild("Humanoid") then
end
local Clone = Sword:Clone()
Clone.Parent = player.Backpack
end)
local ToolNumber1 = math.floor(1, 1) --Returns a number between 1 and 10.
local ToolNumber2 = math.floor(1, 1) --Also returns a number between 1 and 10.
print(ToolNumber1, ToolNumber2)
-- Randomly Pick The Tool
function onTouched(hit)
if hit.Parent:findFirstChild("Humanoid") then
print("Hit")
print(ToolNumber1)
if ToolNumber1 == 1 then
print("Tool 1 Was Given To The Player ")
if ToolNumber1 == 1 then
local Sword = game.ReplicatedStorage.Tools:WaitForChild("ClassicSword")
function onTouched(hit)
if hit.Parent:findFirstChild("Humanoid") then
end
local Clone = Sword:Clone()
Clone.Parent = player.Backpack
end)
end
end
I know math.floor is currently a 100% chance of “1”, I’m testing that’s why.
local ToolNumber1 = math.random(1, 10) --Returns a number between 1 and 10.
local ToolNumber2 = math.random(1, 1) --Also returns a number between 1 and 10.
print(ToolNumber1, ToolNumber2)
-- Randomly Pick The Tool
function onTouched(hit)
if hit.Parent:findFirstChild("Humanoid") then
print("Hit")
print(ToolNumber1)
if ToolNumber1 == 1 then
print("Tool 1 Was Given To The Player ")
if ToolNumber1 == 1 then
local Sword = game.ReplicatedStorage.Tools:WaitForChild("ClassicSword")
function onTouched(hit)
if hit.Parent:findFirstChild("Humanoid") then
end
local Clone = Sword:Clone()
Clone.Parent = player.Backpack
end)
end
end
end
end)
local ToolNumber1 = math.random(1, 10) --Returns a number between 1 and 10.
local ToolNumber2 = math.random(1, 1) --Also returns a number between 1 and 10.
print(ToolNumber1, ToolNumber2)
-- Randomly Pick The Tool
function onTouched(hit)
if hit.Parent:findFirstChild("Humanoid") then
print("Hit")
print(ToolNumber1)
if ToolNumber1 == 1 then
print("Tool 1 Was Given To The Player ")
if ToolNumber1 == 1 then
local Sword = game.ReplicatedStorage.Tools:WaitForChild("ClassicSword")
function onTouched(hit)
if hit.Parent:findFirstChild("Humanoid") and game.Players:GetPlayerFromCharacter(hit.Parent) ~= nil then
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
local Clone = Sword:Clone()
Clone.Parent = player.Backpack
end
end)
end
end
end
end)