Yo!
So I’m trying to make a rock that you can mine, and right now I’m having an issue with the tool I made for it. I have a BoolValue in the tool to indicate when the tool is ‘mining’ and for some reason, even though the script can see that the bool exists, and the function to change the value of the bool works, (In a different script) I can’t get the script within the tool to see the value of the bool. For example, I can do if mining then print("exists") (mining is the variable for the bool) then I get ‘exists’ in the output. However, if I do if mining.Value == true then print("It's true") I don’t get anything.
Here’s the script I have right now:
local mining = script.Parent.Mining
local debounce = script.Parent.Debounce
local hit = false
script.Parent.Handle.TouchPart.Touched:Connect(function(t)
if t.Parent.Name == "Rock" then
if mining.Value == true then
print("Let's Mine!")
t.Parent.Health.Value = t.Parent.Health.Value - 1
mining.Value = false
end
end
end)
mining.Changed:Connect(function()
print("Change!")
end)
if mining then
print("Bool Exists")
end
if mining.Value == true then
print("Mining is true")
end
And here a picture of the hierarchy:
Mining is the script I sent.
Thanks!
is not under the changed function. So assuming that the boolean value is set to false before loading, of course it won’t print anything, and it’ll only get checked the first instance it loads.
The other problem is that you’re not changing the actual value of that boolean. You’re only setting the variable itself to be false.
Are you absolutely sure there is no errors? What happens when you comment out the Touched event and just see if it prints “Change!” when you change the value.
I commented out the entire function (line 5-13) and still got no ‘Change!’. And the only errors I get are from plugins. I have no idea what’s happening. I’m okay with offering a download of the place or maybe even a Team Create.
Well in that case… what’s the default value of the mining boolean? If it’s already set to false, then setting it to false again won’t fire the changed function.
I’ve also noticed that there’s nothing setting it to true. It needs to be changed between the 2 to actually fire.