Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Error with Mouse?

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)

1 comment

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

1 answer

✓ Accepted answer

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!

1 comment

0

Good job.

This discussion is preserved as it was. New answers, comments, and votes are closed.