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

MouseButton1Click LocalScript are not working and the Output doesnt show anything, why?

Asked by 5 years ago

So I'm a new roblox developer and I made a script that for some reason won't work, can someone help me out?

script.Parent.MouseButton1Click:Connect(function(player)
    if game.Players.LocalPlayer.refill.Reff.Value == 0 then wait()
    game.Players.LocalPlayer.refill.Reff.Value = 1
end
end)

both **refill and Reff are somes strings that I made*

1 answer

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

I use it like this

--Say where the button is located
--(in my case player.PlayerGui.Guiscreen.frame.button
--so my script is in the Guiscreen)

local GoldButton, state = script.Parent.GiveFrame.GoldButton, false

GoldButton.MouseButton1Down:connect(function(player#(=game.Players.Player that clicked)#)

    --Make a Value so u dont need to repeat the game.blablabla-stuff.
    local PRV = player#(=game.Players.Player that clicked)#.refill.Reff

    if state == false then
        state = true
        if  PRV.Value ==  0 then 
            wait()
            PRV.Value = 1
        else
            PRV.Value = 0
        end
    else
        state = false
    end
end)

or when click on parts

-- The door 'BasePart'

local door = script.Parent

-- Asset ID of the image you want the to set the cursor to

local CursorId = "3190239131"

-- Create a ClickDetector

local ClickDetector = Instance.new("ClickDetector")

ClickDetector.Parent = door

ClickDetector.MaxActivationDistance = 15

ClickDetector.CursorIcon = "rbxassetid://"..CursorId


ClickDetector.MouseHoverEnter:Connect(function()

end)

ClickDetector.MouseHoverLeave:Connect(function()

end)

ClickDetector.MouseClick:Connect(function(player#(player  that clicked or part that they need to click on)#)

end)

ClickDetector.RightMouseClick:Connect(function(player)

end)

Del the #.....# parts they are just explaining

Ad

Answer this question