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

How can I fix this unequipped weapon function?

Asked by 10 years ago

So, the code below is a part of a gun script I am working on. I want to make it so when the weapon is unequipped your cursor returns to default, I am not sure why this wont work.

function un(mouse)
    mouse.Icon = nil
    end

tool.Unequipped:connect(un)

This is in a local script. This is only a part of the script that deals with unequipping

Error: 13:44:25.265 - Players.Player1.Backpack.Disrupter.IFF:45: attempt to index local 'mouse' (a nil value) 13:44:25.266 - Stack Begin 13:44:25.266 - Script 'Players.Player1.Backpack.Disrupter.IFF', Line 45 13:44:25.266 - Stack End 13:44:25.267 - Disconnect

All help is appreciated, thanks!

1 answer

Log in to vote
0
Answered by 10 years ago

The mouse cannot be used after the tool has been equipped, which is why your script is breaking.

That being said, you should not have to reset the icon yourself, the mouse icon will automatically reset itself the Tool is Unequipped. If it does not, double check UserInputService.MouseIconEnabled.

0
It does not automatically reset the mouse if the weapon is unequipped, even if I reset. ggggyourface23 63 — 10y
0
It does for me. Try re-installing ROBLOX? DaMrNelson 130 — 10y
Ad

Answer this question