Hi, I made a script where the player chops a tree down when they click with their mouse. I made a boolean to let the script detect when the player clicked because using a touched event didn't work with a local script. I have no idea why this does not work can someone please help me. Thanks.

Click Script (local script):

local plr = game.Players.LocalPlayer

local mouse = plr:GetMouse()

local arm = workspace.Arm1.Union


local axe = workspace.wdaxe


local cam = workspace.Camera

mouse.Button1Down:Connect(function(valuse)
	
	if script.Parent.Script.swngV.Value == false then
	
		print("mouse lol")
	
	script.Parent.Script.swngV.Value = true
	
	for i = 1, 7 do
		
		wait()
		
	end
	
	
	wait(.5)
	
	
	script.Parent.Script.swngV.Value = false
	
	end
	
end)

Chop Down Tree Script (script):

script.Parent.Touched:Connect(function(chop)

	
	wait(.05)
	
	if chop.Parent.Name == "Tree" then
		
		print("tree has been touched okay")
		
		script.swngV.Changed:Connect(function(ch0p)
		
		print("wood was chopped")
		
		
		script.Parent.WoodHit:Play()
		
		
		
		for i = 1, 7 do
			
			wait()
			
		end
		
		
		wait(.5)
		
		
				
		end)	
		
		
	end
	
	
	
end)

When I use print() it prints when the mouse is clicked and when the axe is touching the tree. But the only thing that seems to be wrong is the Boolean Value since it doesn't print.

2 comments

0

If you change a value from local script, the server not detect because its only for u

0

Yep. Can't do this in the filtering enabled world of Roblox 2019. You have to send a RemoteEvent from client to server. Value objects were the old, insecure way of replicating arbitrary values which is no longer allowed.