Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Can someone help me fix my click detector script that's not working right?

Asked by 5 years ago
Edited 5 years ago

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
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 theking48989987 2147 — 5y
0
Any errors? Use ServerStorage to store 'Planks'. hellmatic 1523 — 5y
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 theking48989987 2147 — 5y
0
There are no errors, and I just moved it there. protectiverobos -50 — 5y
View all comments (5 more)
0
Output print (? proPVPgamers_YT 40 — 5y
0
Nothing, and I dont know how to use remote events. protectiverobos -50 — 5y
0
No output. protectiverobos -50 — 5y
0
the click detector is inside a part right? hellmatic 1523 — 5y
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)" protectiverobos -50 — 5y

Answer this question