Can't derive value from bool

Yes, it is Local. But I use a BoolValue instance, not a variable. I think even if it’s local, if I use an instance it’ll be visible to the server.

Regardless, if a localScript changes something that is visible to the server, the change will only be visible to your client. That’s why you’re not getting a change.

1 Like

So should I run a RemoteEvent to get this to the server?

Right, or anything that allows a client to send information to the server.

1 Like

Try something like this:
Client

local debounce = script.Parent:WaitForChild("Debounce")
local mining = script.Parent:WaitForChild("Mining")
local updateEvent = script.Parent:WaitForChild("Update");

script.Parent.Activated:Connect(function()
	if debounce.Value == false then
		local anim = game.Players.LocalPlayer.Character:WaitForChild("Humanoid"):LoadAnimation(script.Animation)
		anim:Play()
		updateEvent:FireServer("Mining", true);
		updateEvent:FireServer("Debounce", true);
		wait(.75)
		updateEvent:FireServer("Mining", false);
		wait(.25)
		updateEvent:FireServer("Debounce", false);
	end
end)

mining.Changed:Connect(function()
	if mining.Value == true then
		print("Mining_True")
	else
		print("Mining_False")
	end
end)

Server

local mining = script.Parent:WaitForChild("Mining");
local debounce = script.Parent:WaitForChild("Debounce");
local updateEvent = script.Parent:WaitForChild("Update");
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)

updateEvent.OnServerEvent:Connect(function(player, obj, value)
	script.Parent[obj].Value = value;
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

if mining and mining.Value then
    print ("mining is true")
end

print(mining.ClassName)

EDIT: Forgot to make debounce false, changed now.

1 Like

More specifically, have the LocalScript send a singal through the RemoteEvent, and have the change happen via the normal script.

If you’re uncertain how to use a RemoteEvent, you can reference this article, or look at this page that lists all of the functions/events.

1 Like

I make a RemoteEvent then name it ‘Update’ and put it inside the tool, correct?

That is correct, yes. Make sure it is inside the tool itself.

1 Like

Okay, now I get change, but I don’t get “Mining is true”.

That only runs when the script first executes. I tested it and the rock did break for me.

1 Like

Cool, and I changed the print to the .changed function so it happens every time. Also, I don’t know if this is happening for you but the rock is supposed to be going down 1 health every time, but just give an error then breaks in three* hits. So it’s doing what it’s supposed to but not showing it right.

Edit: I think I know how to fix this though.

Nevermind, I do not know how to fix it. :sweat_smile: What’s happening is that it’s dealing with multiple damage for every swing, but I only want one damange per swing. That’s why I have a debounce. I can’t really figure it out though…

Here is what I have and it seems to work pretty well.
Rock Place.rbxl (70.4 KB)

2 Likes

Wow. This is perfect, it’s exactly what I had in mind. Thank you so very much. One thing before you go, can you explain to me what [ ] and ; do? Sorry for the late response, had to head to bed.