I’m trying to make it so when a part has a transparency of 0.1, a UI frame will pop up. I’m not sure why my code isn’t working.
local orb = game.Workspace:FindFirstChild("Orbz")
local frame = game.StarterGui.ScreenGui.Frame
if orb and orb:IsA("Part") then
if orb.Transparency == 0.1 then
frame.Visible = true
else
frame.Visible = false
end
else
frame.Visible = false
end
This currently only checks when the player loads in, so if the part’s transparency isn’t 0.1 upon loading in, it won’t show.
You can use :GetPropertyChangedSignal() with “Transparency” as the property and have it check with your current if statement.
local orb = game.Workspace:FindFirstChild("Orbz")
local frame = game.StarterGui.ScreenGui.Frame
orb:GetPropertyChangedSignal("Transparency"):Connect(function()
if orb and orb:IsA("Part") then
if orb.Transparency == 0.1 then
frame.Visible = true
else
frame.Visible = false
end
else
frame.Visible = false
end
end)
What I want is when a player clicks a part, the the transparency turns to 0.1 (already have the code for it) and then when transparency turns 0.1, a ui pops up. Where do I put the screengui besides StarterGui?
Sure. First can you slide me that click detector script. We need to get the player thats clicks it before anything, as when using remote events, we need to mention a client
local Orbz = game:GetService("Workspace"):WaitForChild("Orbz")
local object = script.Parent
local clickdetector = script.Parent.ClickDetector
clickdetector.MouseClick:Connect(function(player)
if player then
local char = player.Character or player.CharacterAdded:Wait()
local tool = player.Backpack:FindFirstChildWhichIsA("Tool")
local at = game:GetService("Workspace"):WaitForChild("ar")
print(tool.Name)
if tool and tool.Name == "ToolA" then
script.Parent.Transparency = 0.1
at.BrickColor = BrickColor.new("Hot pink")
tool:Destroy()
end
end
end)
local Orbz = game:GetService("Workspace"):WaitForChild("Orbz")
local object = script.Parent
local clickdetector = script.Parent.ClickDetector
local RemoteEvent = nil --replace with remote event pathway
clickdetector.MouseClick:Connect(function(player)
if player then
local char = player.Character or player.CharacterAdded:Wait()
local tool = player.Backpack:FindFirstChildWhichIsA("Tool")
local at = game:GetService("Workspace"):WaitForChild("ar")
print(tool.Name)
if tool and tool.Name == "ToolA" then
script.Parent.Transparency = 0.1
RemoteEvent:FireClient(player)
at.BrickColor = BrickColor.new("Hot pink")
tool:Destroy()
end
end
end)
Local script inside the GUI:
local RemoteEvent = nil -- replace with pathway to remote!
local orb = game.Workspace:FindFirstChild("Orbz")
local frame = --"game.StarterGui.ScreenGui.Frame" Change it to the pathway of the frame with script.Parent(s)
RemoteEvent.OnClientEvent:Connect(function())
if orb and orb:IsA("Part") then
if orb.Transparency == 0.1 then
frame.Visible = true
else
frame.Visible = false
end
else
frame.Visible = false
end
end)
All you need to do is make a Remote event, give it a name, and change it (and anything else) in both of these scripts. Remote Events works by Sending a signal to the client, and allowing the client to run code. Server is like a master client that effects everyone, and the client is what you see. So as a safety issue, roblox seperates the server from the clients. So that leaves remote events being important, as that can work through the filter! So we just listen for that to happen. You can learn more here on remote events!
First code is just your click detector code. idk where you put that to make it work, but shouldn’t matter as long as its a server script, and inside a container that runs server scripts
--Parented inside the Part
script.Parent.ClickDetector.MouseButton1Click:Connect(function()
script.Parent.Transparency = 0.1
end)
The UI script:
--Parented inside the ScreenGui
workspace.Part:GetPropertyChangedSignal("Transparency"):Connect(function()
if workspace.Part.Transparency == 0.1 then
script.Parent.Frame.Visible = true
end
end)
I have had past issues with the :GetPropertyChangedSignal() function, so this might not work.