nothing is destroying at all. and the touch statement doesn’t go off at all, even if touched.
Wait I found the problem, it’s Destroy(), not destroy().
hit:destroy()
You need to capitalize the “d” there.
You realize that it can’t be touched if it’s in ServerStorage, right?
EDIT - (read it wrong)
We just tried that, but it still didn’t fix it.
The statement isn’t going off at all, we made it so it prints something when touched, and it isn’t printing a statement.
Your saying if humanoid is equal to nil that means they have to be dead
Your currently trying to set the Touched Event to the model itself and not the parts inside of it, so the fix for your problem would to simply get all the parts and then give them a Touched Event that listens for when a player touches them like this:
destroying = script.Parent
local modelParts = destroying:GetChildren() -- This returns a table
for _, part in next, modelParts do
part.Touched:Connect(function(hit)
local Character = hit.Parent
local Humanoid = Character:FindFirstChildOfClass("Humanoid")
local player = game:GetService("Players"):GetPlayerFromCharacter(Character) -- We get the player so we can give him money
if Humanoid then
hit:Destroy()
player.leaderstats.Coins.Value = player.leaderstats.Coins.Value + 5
end
end)
end
My method will work but it requires you to have leaderstats, you can create a simple one with this:
-- Put this in ServerScriptService
game:GetService("Players").PlayerAdded:Connect(function(player)
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats" -- Folder has to be named leaderstats
leaderstats.Parent = player
local coins = Instance.new("IntValue")
coins.Name = "Coins"
coins.Parent = leaderstats
end)
Now this will 100% work for you, just make sure that destroying is a model including parts that is in workspace and that the leaderstats script is in ServerScriptService
Also do not do that, your only giving them stuff if their humanoid doesn’t exist, instead it should be:
if humanoid ~= nil then
And also an error here, this should be :Destroy(), hope that I helped you, do not hesitate to tell me if there are any errors!
Humanoid == nil means that the model does not have a humanoid. This is how i am checking to make sure it is not a player, and parts do not have humanoids in them so it should work.
The actual problem is the touched event is not going off at all
not the destroy or the if statement
You’re making a “dropper”, correct?
No. We have a dropper, we are doing the end of the conveyor, in which when the blocks reach the end, they get destroyed.
We will try this method right now!
We tried it, and it unfortunately didn’t work. It didn’t give any errors either.
Could you show me where the “destroying” model is located? Screenshot it’s tree to me.
EDIT: Also make sure that you use my leaderstats script too.
The image:
Our old leaderstats script:
game.Players.PlayerAdded:Connect(function(player)
local leaderstats = Instance.new("Folder", player)
leaderstats.Name = "leaderstats"
leaderstats.Parent = player
local cash = Instance.new("IntValue")
cash.Name = "Cash"
cash.Parent = leaderstats
cash.Value = 5
local givemoney = Instance.new("IntValue", game.ServerStorage)
givemoney.Name = "moneytogive"
end)
We did insert your leaderstat script, and substitute “coins” for “cash”
Any advice would be helpful at this point.
I don’t see “destroying” anywhere, is it inside of the “Tycoon” folder or did you use the wrong name?
Keep in mind that my script is made for a model called “destroying”
The variable “destroying” is the part that it touches to get deleted.
So I just tested out the script in studio, and it worked fine. Can you also send a screenshot of givemoney in the explorer? The problem may be coming from there. I’m assuming there weren’t any errors btw.
If it’s a part then my script won’t work, you said that you made a new model and put the script inside of it so I assumed that “destroying” is a model, but if you convert the part into a model with parts inside of it then my script will work if u put it inside of the model in that case.