Tool Script (LocalScript) -- Tool is in StarterPack Tool.Name is the ore name
tool = script.Parent
ReplicatedStorage = game.ReplicatedStorage
dropEvent = ReplicatedStorage:WaitForChild("dropEvent")
function drop()
local oreName = tool.Name
local Player = tool.Parent.Name
print("Calling Event")
dropEvent:FireServer(Player, tool.Name, tool)
tool.Number.Value = tool.Number.Value - 1
verif()
end
function verif()
if tool.Number.Value <= 0 then
tool:Destroy()
end
end
tool.Activated:Connect(drop)
Event Script (server Script) -- In ServerScriptService
ReplicatedStorage = game.ReplicatedStorage
dropEvent = Instance.new("RemoteEvent", ReplicatedStorage)
dropEvent.Name = "dropEvent"
local function drop(Player, oreName, tool)
print("Event called")
print(Player, " ", oreName, " ", tool)
local Ore = game.ReplicatedStorage.Ores:FindFirstChild(oreName)
local newOre = Ore:Clone()
newOre.Owner.Value = Player
newOre.Name = "Ore"
newOre.Ore.Value = oreName
newOre.Parent = workspace.Loots
end
dropEvent.OnServerEvent:Connect(drop)
-- Studio Test Output -- Calling Event Event called alancretel1999 alancretel1999 Stone 13:14:15.214 - ServerScriptService.lootOre:10: attempt to index local 'Ore' (a nil value) 13:14:15.216 - Stack Begin 13:14:15.218 - Script 'ServerScriptService.lootOre', Line 10 13:14:15.219 - Stack End
-- Studio Team Test Output -- Calling Event
Thanks for your help, I'm new inLocalScript and custom events

1 comment
ores are in the ReplicatedStorage.Ores this should work, I changed tool.Parent.Name by game.Players.LocalPlayer and newOre.Owner.Value = Player.Name and i get the same outputs :/