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

[SOLVED] Decal wont hide on Button2Up when testing on Play Mode?

So, I put a crosshair decal on my gun and i want it to show when i hold Right Click and hide when i let go of Right Click. It works in studio but it doesn't work when i test it on a Roblox server. BTW: This is a part inside a tool. Here is the script:

local tool = script.Parent.Parent
local mouse = game.Players.LocalPlayer:GetMouse()
local decal = script.Parent.Decal
decal.Transparency = 1

tool.Equipped:connect(function()
	mouse.Button2Down:connect(function()
	script.Parent.Decal.Transparency = 0
end)

	mouse.Button2Up:connect(function()
	script.Parent.Decal.Transparency = 1
end)
end)

tool.Unequipped:connect(function()
	script.Parent.Decal.Transparency = 1
end)

Thanks!

3 comments

0

local or server (normal)?

0

Its a normal script.. not a local, it is inside the part with the decal and the part is inside the tool

0

Wait, should it be local?

1 answer

local tool = script.Parent.Parent
local mouse = game.Players.LocalPlayer:GetMouse()
local decal = script.Parent.Decal
decal.Transparency = 1

tool.Equipped:connect(function()
    mouse.Button2Down:connect(function()
    script.Parent.Decal.Transparency = 0
end)

mouse.Button2Up:connect(function()
    script.Parent.Decal.Transparency = 1
end)
--[[There was an Extra end) ]]

tool.Unequipped:connect(function()
    script.Parent.Decal.Transparency = 1
end)

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