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!
making a mining game
What is the issue? Include screenshots / videos if possible!
exception while signaling: Must be a LuaSourceContainer printed 3225 times
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
no
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!
i couldnt found where was the error was coming
Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.
wait wait i think the error was comming from this script
amnt = 700 --how much you get for it
function onTouched(part)
local h = part.Parent:findFirstChild("Humanoid")
if (h~=nil) then
local thisplr = game.Players:findFirstChild(h.Parent.Name)
if (thisplr~=nil) then
local stats = thisplr:findFirstChild("leaderstats")
if (stats~=nil) then
local score = stats:findFirstChild("Blocks")
if (score~=nil) then
score.Value = score.Value + amnt
end
end
end
script.Parent:remove()
end
end
script.Parent.Touched:connect(onTouched)
amnt = 700 --how much you get for it
function onTouched(part)
local h = part.Parent:findFirstChild("Humanoid")
if h then
local thisplr = game.Players:findFirstChild(h.Parent.Name)
if thisplr then
local stats = thisplr:findFirstChild("leaderstats")
if stats then
local score = stats:findFirstChild("Blocks")
if score then
score.Value += amnt
end
end
end
script.Parent:remove()
end
end
script.Parent.Touched:connect(onTouched)
I can’t find any errors, but I polished your code. Is the first parameter, part, being returned in a print()?
--//Services
local Players = game:GetService("Players")
--//Variables
local Part = script.Parent
--//Controls
local amount = 700
--//Functions
Part.Touched:Connect(function(hit)
local player = Players:GetPlayerFromCharacter(hit.Parent)
if player then
Part:Destroy()
player.leaderstats.Blocks.Value += amount
end
end)
I delete the parent first so that in the split milliseconds that it takes for the value to add, the player can’t fire the touched event again. It’s just a prevention for that edgecase.