Before you read this im new at lua scripting and roblox studio so have than in considerament. Thank you for understanding.
So im trying to make a script to change the mouse icon, but idk why it isn't working. Im using a local script lol. P.S.if there's anything that's writed wrong its because i cant go to roblox studio right now and copy my code. Anyways... here's the code.
ThE cOdE :
local player = game.Players.LocalPlayer local mouse = game.Players.LocalPlayer:getMouse() game.StarterPack.Gun.equipped:connect(function() mouse.Icon = "rbxassetid://358948941" end
The idea is when the gun is equipped the mouse icon change, but it isn't working, pls help me fixing this.
First, you're reusing code that's already been defined. Why don't you just do player:GetMouse()
. Variables are there for you to use.
Second, you're not accessing the gun that's being equipped. You're connecting the Equip event to the gun in StarterPack. Think of StarterPack as a folder that only copies it's children when a new character spawns. StarterPack isn't something a local player has access to.
If this is a local script and inside a Tool object, then the Tool you want to access can be found using script.Parent
.
local player = game.Players.LocalPlayer local mouse = player:GetMouse() local Tool = script.Parent Tool.Equipped:Connect(function() print("This tool was equipped") mouse.Icon = "rbxassetid://358948941" end)
Equipped event also has a parameter that is the mouse of the player. So you wouldn't need to use line 2.
Take note of how you type your code. GetMouse, Connect, and Equipped should always be capitalized since other forms might be considered deprecated.
starterpack doesnt belong to the player, backpack does, when a player equips their tool, the tool they are equipping is in the backpack of the player, you can see by going to Players>mewantataco>backpack
i assume this is a local script inside the tool so just do
script.Parent.Equipped:Connect(...)