Ok, I changed it to a script but still nothing.
I am sorry to put you through all this but I would not have done all this by myself
math.randomseed(tick())
script.Parent.Touched:connect(function(hit)
print(âAâ)
if hit.ParentFindFirstChild(âHumanoidâ) then
print(âBâ)
script.Disabled = false
local player = game.Players:FindFirstChild(hit.Parent.Name)
local random = math.random(1,100)
if random > 0 and random < 50 then
print(â0-50â)
local sword1 = game.ReplicatedStorage.sword1:Clone()
sword1.Parent = player.BackPack
elseif random > 50 and random < 100 then
print(â50-100â)
local pistol1 = game.ReplicatedStorage.Pistol1:Clone()
pistol1.Parent = player.Backpack
end
script.Parent:Destroy()
end
end)
Add print and show me the output
Do you want me to test then take a screenshot with the output
The error is in the print maybe your â are wrong or something like that
Create an script and copy the:
print(âhello worldâ)
Just modify the hello world into A or B, etc
Oh, change the line 5 into this
hit.Parent:FindFirstChild(âHumanoidâ)
Oh sorry , use this:
if hit.Parent:FindFirstChild(âHumanoidâ) then
NO, change in the line 5
The third was correct
well⌠sorry about that one thats all me
ok so now there is no errors and when I touched the âcrateâ it disappeared but gave me nothing.
ok so hereâs this:
(The rest of the output is just my tycoon stuff, and also there is stuff in my tycoons that need touch up so ignore that)Generally you can define the player and test to see if it is a player, which removes the need for a humanoid
script.Parent.Touched:Connect(function(hit)
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if player then
local randomNumber = math.random(1,100)
if randomNumber <= 50 then
game.ReplicatedStorage.sword1:Clone().Parent = player.Backpack
else
game.ReplicatedStorage.pistol1:Clone().Parent = player.Backpack
end
script.Parent:Destroy()
end
end)
wow. kingerman yours worked thank you
Also thank you to gogols who helped out through everything.
No problem, if you donât mind marking it as the solution so people know that this has been solved
just did that but thank you to you both again.