Script not setting part transparency

  1. What do you want to achieve? A building system highlighting of the current placement position

  2. What is the issue? Its not setting the part transparency

local mouse = game:GetService('Players').LocalPlayer:GetMouse()
local uis = game:GetService('UserInputService')
local hoveringOver = nil
local lastTransparency = nil

uis.InputBegan:Connect(function(input,gameProcessed)
	if gameProcessed then return end
	
	if input.UserInputType == Enum.UserInputType.MouseButton2 then
		if not hoveringOver then return end
		if hoveringOver.Parent.Name == 'Normal' then
			print("Normal")
		elseif hoveringOver.Parent.Name == 'Sniper' then
			print('Sniper')
		end
	end
end)
	

while wait() do
	hoveringOver = mouse.Target
	
	if hoveringOver then
		if hoveringOver:FindFirstChild('isBuildPos') then
			if hoveringOver:FindFirstChild('isBuildPos').Value then
				lastTransparency = hoveringOver
				hoveringOver.Transparency = 0.8
			end

		end
	end
	if lastTransparency then lastTransparency.Transparency = 1 end
end

Hello, first I would change that while loop into a RenderStepped such as…

game:GetService("RunService").RenderStepped:Connect(function()
        --Code here.
end)

Also how do you have this laid out in explorer?

LocalScript (PatriikPlays Editing) - Roblox Studio 30_10_2020 11_56_16 PM (2)

What does ā€œisBuildPosā€ value equal to?

1 Like

What is the .Value of:

if hoveringOver:FindFirstChild(ā€˜isBuildPos’).Value then

is it a BoolValue or a numerical value?

ā€˜isBuildPos’ is equal to true LocalScript (PatriikPlays Editing) - Roblox Studio 31_10_2020 12_01_49 AM (2)

Is the parent of isBuildPos a part?

LocalScript (PatriikPlays Editing) - Roblox Studio 31_10_2020 12_00_34 AM (2)

Where is the script located and is it a localscript? Essentially this should work if everything is placed correctly.

The script is a child of StarterGui.

Also whats the point of .8 transparency if it will automatically turn the transparency to 1?

That is probably your problem.

Oh I put the transparency changing line after the transparency gets changed to 0.8

The only thing I can think of that will make the script not work is if the character isn’t loaded in. I can test this right now and I’m positive it will work. Let me do a small test on studio right now.

Its already solved if you didnt see the mssage i sent

Oh you kind of confused me there.