Hello! I am experiencing a bug/error where I can’t set a custom crosshair to the player’s mouse, how can I fix this? The mouse icon is set after loading, but then resets after the mouse moves, I’ve tried using loops to set it but those crash Roblox Studio.
if equipped == true then
script.Parent.Remotes.PlayEquipAnimation:FireServer(player)
local mouse = player:GetMouse()
mouse.Icon = script.Parent.Configuration.CrossHairId.Value
end```
You forgot to add the wait() so your game crashes
For loops you have to do:
while true do
wait()
if equipped == true then
script.Parent.Remotes.PlayEquipAnimation:FireServer(player)
local mouse = player:GetMouse()
mouse.Icon = script.Parent.Configuration.CrossHairId.Value
end
end
If you could show more of the script then that could help get a better view of what’s going on.
If you’re trying to use loops, you then need to do one of the following:
1- you said looping was crashing ROBLOX right? Then you’re probably using while true do, which crashes ROBLOX. Instead, you could use while wait() do, which will not crash the game.
2- you could do something like repeat wait() until not equipped - not sure if that’d work in your case, but give it a try, might work for you.
Separate the 2 scripts so you just do this on its own:
coroutine.wrap(function()
while true do
wait()
if equipped == true then
local mouse = player:GetMouse()
mouse.Icon = script.Parent.Configuration.CrossHairId.Value
end
end
end)();
then just put the animation part under or over it.