My click detector script, isn't working, can someone help?

local function playerWhoClicked(player)
print('player who clicked is ' .. player.Name)
	local p = player.PlayerGui.Inventory.main.container.Wood.Wood.HowMany

	if script.Parent.Parent.Enabled.Value == false then
	if p.Value > 0 then
	p.Value = p.Value - 1
	local clone = game.Lighting.Planks:Clone()
	clone.Parent = workspace
	script.Parent.Parent.Enabled.Value = true
	
	else player.PlayerGui.O.Enabled = true
		wait(1.5)
		player.PlayerGui.O.Enabled = false
	end
	else player.PlayerGui.N.Enabled = true
		wait(1.5)
		player.PlayerGui.N.Enabled = false
	end
	end
script.Parent.MouseClick:Connect(playerWhoClicked)

Code^

I also have this script to work with the click detector.

function onClicked(Player)
    local Wood = Player.PlayerGui.Inventory.main.container.Wood.Wood.HowMany
script.Parent.MouseButton1Click:connect(function()
if script.Parent.Enabled.Value == false then
--if Wood.Value == 0 then
--	Wood.Value = Wood.Value - 0
	local Planks = game.Lighting.Planks:Clone()
	Planks.Parent = workspace
	Planks.Position = game.Lighting.Planks.Position
end
--end
end)
end

9 comments

0

well, you should use a local script the modify the player gui, first because mouseclick events can be listened to on the client, and second, thats the only way to modify a player's gui elements

0

Any errors? Use ServerStorage to store 'Planks'.

0

also for your case, I d recommend either having two listener scripts, one local and one server script or to use a remote event

0

There are no errors, and I just moved it there.

0

Output print (?

0

Nothing, and I dont know how to use remote events.

0

No output.

0

the click detector is inside a part right?

0

Yes, it is. I got this error"19:24:28.449 - https://www.roblox.com/client-status/set?browserTrackerId=29590964865&status=LeftGame: CURL error (curl_easy_perform): Couldn't connect to server (7)"