You can write your topic however you want, but you need to answer these questions:
-
What do you want to achieve? Keep it simple and clear!
I want to make it so that when you click a coin, every second it decreases (mines) the coin’s hp by 1 and click it again or click another coin and it cancels the mining -
What is the issue? Include screenshots / videos if possible!
When i tried making that it ended up either saying an error or just straight up saying nothing. -
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I tried making remote function and the script using it but it ended up saying “attempt to call table value” and i tried other solutions but they didn’t work
After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
local script
local e = game.ReplicatedStorage.Events.mineCoin
local f = false
local result = e:InvokeServer()
result[2].ClickDetector.MouseClick:Connect(function(m)
if type(result) == "table" then
if not f then
f = true
result[1](m)
result[3].Enabled = true
elseif f then
f = false
result[1](m)
result[3].Enabled = false
end
end
end)
server script
local c = script.Parent
local maxhp = c.Parent.mhp
local hp = c.Parent.hp
local bb = c.BillboardGui
local t = {}
local e = game.ReplicatedStorage.Events.mineCoin
local already_mining = script.mining
local function mineCoin(plr)
local plrmining = plr:FindFirstChild("is_m")
table.insert(t, c.ClickDetector)
table.insert(t, c.BillboardGui)
if already_mining.Value == false and plrmining.Value == false then
already_mining.Value = true
plrmining.Value = true
bb.Enabled = true
repeat
if plrmining.Value == false or already_mining.Value == false or hp.Value <= 0 then
break
end
wait(1)
hp.Value -= 1
until hp.Value <= 0 or plrmining.Value == false or already_mining.Value == false
if plrmining.Value == false and already_mining == false then
already_mining.Value = false
plrmining.Value = false
bb.Enabled = false
return t
elseif hp.Value == 0 and plrmining.Value == true and already_mining.Value == true then
plrmining.Value = false
c.Parent:Destroy()
end
else
plrmining.Value = false
already_mining.Value = false
bb.Enabled = false
return t
end
return t
end
e.OnServerInvoke = t
Any help will be welcomed!