So i'm trying to make a basic ore collection. The collection works by a pickaxe hitting a rock. If the rock name corresponds to the script, give them that ore.
That all works fine... However, my scripts seems to give the resource to all players rather than just one...
Any ideas?
game.ReplicatedStorage.Oof.OnServerEvent:Connect(function(player)
local playersname = player.Name
local FolderName = game.ServerScriptService:FindFirstChild(playersname)
if FolderName then
if script.Parent.InUse.Value == false then
script.Parent.InUse.Value = true
local kickAnimation = Instance.new("Animation")
kickAnimation.AnimationId = "rbxassetid://704173649"
local kickAnimationTrack = player.Character.Humanoid:LoadAnimation(kickAnimation)
kickAnimationTrack:Play()
wait(1.5)
script.Parent.InUse.Value = false
else
print("Nope")
end
end
local function Kill (hit)
if hit.Parent.Name == "Rock" and script.Parent.Debounce.Value == false and script.Parent.InUse.Value == true then
script.Parent.Debounce.Value = true
FolderName.Stone.Value = FolderName.Stone.Value + 1
player.PlayerGui.Inventory.Main.Frame.Items.Stone.TextButton.Text = "Stone: ".. FolderName.Stone.Value
A = game.ServerScriptService.Notify
B = A:Clone()
B.Value.Value = "Rock + 1"
B.Parent = player.PlayerGui
hit.Parent.Damage.Value = hit.Parent.Damage.Value +1
print(playersname)
B.Disabled = false
wait(1.5)
B:Destroy()
script.Parent.Debounce.Value = false
print(script.Parent.Debounce.Value)
end
if hit.Parent.Name == "Copper" and script.Parent.Debounce.Value == false and script.Parent.InUse.Value == true then
script.Parent.Debounce.Value = true
FolderName.Copper.Value = FolderName.Copper.Value + 1
player.PlayerGui.Inventory.Main.Frame.Items.Copper.TextButton.Text = "Copper: ".. FolderName.Copper.Value
A = game.ServerScriptService.Notify
B = A:Clone()
B.Value.Value = "Copper + 1"
B.Parent = player.PlayerGui
hit.Parent.Damage.Value = hit.Parent.Damage.Value +1
B.Disabled = false
wait(1.5)
script.Parent.Debounce.Value = false
print(script.Parent.Debounce.Value)
B:Destroy()
end
if hit.Parent.Name == "Tin" and script.Parent.Debounce.Value == false and script.Parent.InUse.Value == true then
script.Parent.Debounce.Value = true
FolderName.Tin.Value = FolderName.Tin.Value + 1
player.PlayerGui.Inventory.Main.Frame.Items.Tin.TextButton.Text = "Tin: ".. FolderName.Tin.Value
A = game.ServerScriptService.Notify
B = A:Clone()
B.Value.Value = "Tin + 1"
B.Parent = player.PlayerGui
hit.Parent.Damage.Value = hit.Parent.Damage.Value +1
B.Disabled = false
wait(1.5)
script.Parent.Debounce.Value = false
B:Destroy()
print(script.Parent.Debounce.Value)
end
if hit.Parent.Name == "Gold" and script.Parent.Debounce.Value == false and script.Parent.InUse.Value == true then
script.Parent.Debounce.Value = true
FolderName.Gold.Value = FolderName.Gold.Value + 1
player.PlayerGui.Inventory.Main.Frame.Items.Gold.TextButton.Text = "Gold: ".. FolderName.Gold.Value
A = game.ServerScriptService.Notify
B = A:Clone()
B.Value.Value = "Gold + 1"
B.Parent = player.PlayerGui
hit.Parent.Damage.Value = hit.Parent.Damage.Value +1
B.Disabled = false
wait(1.5)
B:Destroy()
script.Parent.Debounce.Value = false
print(script.Parent.Debounce.Value)
end
if hit.Parent.Name == "Iron" and script.Parent.Debounce.Value == false and script.Parent.InUse.Value == true then
script.Parent.Debounce.Value = true
FolderName.Iron.Value = FolderName.Iron.Value + 1
player.PlayerGui.Inventory.Main.Frame.Items.Iron.TextButton.Text = "Iron: ".. FolderName.Iron.Value
A = game.ServerScriptService.Notify
B = A:Clone()
B.Value.Value = "Iron + 1"
B.Parent = player.PlayerGui
hit.Parent.Damage.Value = hit.Parent.Damage.Value +1
B.Disabled = false
wait(1.5)
B:Destroy()
script.Parent.Debounce.Value = false
print(script.Parent.Debounce.Value)
end
if hit.Parent.Name == "Clay" and script.Parent.Debounce.Value == false and script.Parent.InUse.Value == true then
script.Parent.Debounce.Value = true
FolderName.Clay.Value = FolderName.Clay.Value + 1
player.PlayerGui.Inventory.Main.Frame.Items.Clay.TextButton.Text = "Clay: ".. FolderName.Clay.Value
A = game.ServerScriptService.Notify
B = A:Clone()
B.Value.Value = "Clay + 1"
B.Parent = player.PlayerGui
hit.Parent.Damage.Value = hit.Parent.Damage.Value +1
B.Disabled = false
wait(1.5)
B:Destroy()
script.Parent.Debounce.Value = false
print(script.Parent.Debounce.Value)
end
if hit.Parent.Name == "Coal" and script.Parent.Debounce.Value == false and script.Parent.InUse.Value == true then
script.Parent.Debounce.Value = true
FolderName.Coal.Value = FolderName.Coal.Value + 1
player.PlayerGui.Inventory.Main.Frame.Items.Coal.TextButton.Text = "Coal: ".. FolderName.Coal.Value
A = game.ServerScriptService.Notify
B = A:Clone()
B.Value.Value = "Coal + 1"
B.Parent = player.PlayerGui
hit.Parent.Damage.Value = hit.Parent.Damage.Value +1
B.Disabled = false
wait(1.5)
B:Destroy()
script.Parent.Debounce.Value = false
print(script.Parent.Debounce.Value)
end
end
script.Parent.Handle.Touched:Connect(Kill)
end)
Thank you.

3 comments
I am very sorry to tell you that not a lot of people are going to read this HUGE 149 lines script and try to find any mistakes. Try finding the problematic part.
Here