What I’m trying to do is change the variable by the name of “OreStatus” to the ore model that has been recently hit, and well, so far it isn’t working as great as I want it to unfortunately. I’ve tried moving things around, but it constantly spits out errors and I’m rather confused. Any help would be appreciated! Below you’ll find the script that I’ve made, rather simple so it shouldn’t be too difficult to debug.
local Tool = script.Parent
local Handle = Tool.Handle
local cooldown = 3
local on_cooldown = false
local replicatedStorage = game:GetService("ReplicatedStorage")
local OreTouchedEvent = replicatedStorage.OreTouchedEvent
local OreStatus = nil
Handle.Touched:Connect(function(hit)
if hit.Parent:IsA("Model") and hit.Parent.Name == "Rock" and not on_cooldown then
OreStatus = hit.Parent.Name
on_cooldown = true
task.wait(cooldown)
on_cooldown = false
OreTouchedEvent:FireServer(OreStatus)
elseif hit.Parent:IsA("Model") and hit.Parent.Name == "IronOre" and not on_cooldown then
OreStatus = hit.Parent.Name
on_cooldown = true
task.wait(cooldown)
on_cooldown = false
OreTouchedEvent:FireServer(OreStatus)
elseif hit.Parent:IsA("Model") and hit.Parent.Name == "GoldOre" and not on_cooldown then
OreStatus = hit.Parent.Name
on_cooldown = true
task.wait(cooldown)
on_cooldown = false
OreTouchedEvent:FireServer(OreStatus)
elseif hit.Parent:IsA("Model") and hit.Parent.Name == "AzureOre" and not on_cooldown then
OreStatus = hit.Parent.Name
on_cooldown = true
task.wait(cooldown)
on_cooldown = false
OreTouchedEvent:FireServer(OreStatus)
end
end)