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

Error with Mouse?

Asked by 8 years ago

The error occurs one line 9, and i get the error Attempt to call a nil value, Any clues?

--Local Script
local plyr = game:GetService("Players").LocalPlayer
local mouse = plyr:GetMouse()
local part = workspace.SPart 

mouse.Move:connect(function()
    if mouse.Target == part then
        mouse.Icon = "http://www.roblox.com/asset/?id=278931719"
if mouse.Target == part and mouse.Button1Down:connect() then
        script.Parent.Parent.Shop.Frame.Visible = true
else mouse.Icon = "http://www.roblox.com/asset/?id=279471758"
    end
end
end)
0
'and mouse.Button1Down:connect() then' that's not how it works at all. http://wiki.roblox.com/index.php?title=Events https://scriptinghelpers.org/blog/events-the-big-engagement Perci1 4988 — 8y

1 answer

Log in to vote
1
Answered by 8 years ago

Instead of using mouse.Move use mouse.Button1Down instead.


Button1Down

This will run the script when the player presses the left button down.

Mouse.Button1Down:connect(function()
    print("Mouse Down")
end)

Final Product

--Local Script
local plyr = game:GetService("Players").LocalPlayer
local mouse = plyr:GetMouse()
local icon = mouse.Icon
local part = workspace.SPart 

mouse.Move:connect(function()
    if mouse.Target == part then
        mouse.Icon = "http://www.roblox.com/asset/?id=278931719"
    else
        mouse.Icon = icon
    end
end)

mouse.Button1Down:connect(function()
    if mouse.Target == part then
        script.Parent.Parent.Shop.Frame.Visible = true
        mouse.Icon = "http://www.roblox.com/asset/?id=279471758" --Where do I put this?
    end
end)

Hope it helps!

0
Good job. ghosteffectz 115 — 8y
Ad

Answer this question