I can’t click on a SurfaceGui adorneed to a Part for some reason when it gets replicated into PlayerGui (from ReplicatedStorage) even though it is supposed to work. However, when I turned off and on the Adornee of the SurfaceGui back, the SurfaceGui works again somehow.
The GUIs also won’t change their visibility when they first appear from the default setting in Roblox Studio when I adjust them in a script.
How do I fix this?
Here are my two scripts which handle the GUI
Server Script:
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local module = require(ReplicatedStorage.KeysModule)
local ProductHandler = ReplicatedStorage.ProductHandler
local Rooms = workspace.Rooms
local Floor1 = Rooms.Room0001
local playersTouched = {}
local function onTouchTrigger(hit, roomNumber)
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
local Display = ReplicatedStorage.ProductsDisplay
local newDisplay
if Display:FindFirstChild("HelpGui") then
warn(player)
newDisplay = Display.HelpGui:Clone()
newDisplay.Parent = player.PlayerGui
end
ProductHandler:FireClient(player, hasDisplay, Display, newDisplay, roomNumber)
end
for _, part in Rooms:GetDescendants() do
if part.Name == "Floor" and part.ClassName == "Part" then
part.Touched:Connect(function(hit)
onTouchTrigger(hit, part.Parent)
end)
end
end
Client Script:
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local ProductHandler = ReplicatedStorage:WaitForChild("ProductHandler")
local GetHints = ReplicatedStorage:WaitForChild("GetHints")
local gui = script.Parent
local RevealHint = gui.Frame.RevealHint
local SkipStage = gui.Frame.SkipStage
local player = Players.LocalPlayer
local function UnavailableButton()
print("touched")
gui.Frame.Visible = false
gui.Message.Visible = true
task.wait(3)
gui.Message.Visible = false
gui.Frame.Visible = true
end
SkipStage.MouseButton1Click:Connect(UnavailableButton)
local function ActivateHint()
gui.Message.Rare.Text = "You need some help?"
gui.Frame.Visible = false
gui.Message.Visible = true
task.wait(1.5)
gui.Message.Rare.Text = "It ain't easy to communicate here without the Host knowing..."
task.wait(2.5)
gui.Message.Rare.Text = "So here's a deal. 50 keys and I'll help ya"
task.wait(1.5)
gui.Buttons.Visible = true
gui.Buttons.Cancel.Activated:Connect(function()
gui.Buttons.Visible = false
gui.Message.Visible = false
gui.Frame.Visible = true
end)
gui.Buttons.Purchase.Activated:Connect(function()
GetHints:InvokeServer()
end)
end
warn("Passed")
ProductHandler.OnClientEvent:Connect(function(hasDisplay, Display, newDisplay, roomNumber)
local function ActivateHint()
warn("remote working")
gui.Message.Rare.Text = "You need some help?"
gui.Frame.Visible = false
gui.Message.Visible = true
task.wait(1.5)
gui.Message.Rare.Text = "It ain't easy to communicate here without the Host knowing..."
task.wait(2.5)
gui.Message.Rare.Text = "So here's a deal. 50 keys and I'll help ya"
task.wait(1.5)
gui.Buttons.Visible = true
gui.Buttons.Cancel.Activated:Connect(function()
gui.Buttons.Visible = false
gui.Message.Visible = false
gui.Frame.Visible = true
end)
gui.Buttons.Purchase.Activated:Connect(function()
local allowHints = GetHints:InvokeServer(roomNumber)
print(allowHints)
gui.Message.Visible = true
gui.Buttons.Visible = false
if not allowHints then
gui.Message.Rare.Text = "Sorry, you don't have enough keys to get a hint"
task.wait(3)
gui.Message.Visible = false
gui.Frame.Visible = true
return
end
for i, v in allowHints do
gui.Message.Rare.Text = v
task.wait(3)
end
end)
end
gui.Message.Visible = false
gui.Buttons.Visible = false
gui.Frame.Visible = false
Display.Parent = ReplicatedStorage
task.wait(10)
Display:SetPrimaryPartCFrame(CFrame.new(hasDisplay[1], hasDisplay[2], hasDisplay[3]) * CFrame.Angles(0, math.rad(hasDisplay[4]), 0))
Display.Parent = roomNumber
-- gui.Adornee = Display.Display
gui.Frame.Visible = true
RevealHint.Activated:Connect(ActivateHint)
end)
Yes, there are some underlying code issues with this, for example, how I have to replicate the script to PlayerGui from ReplicatedStorage for it to work but when I tried putting the script (and GUI) in StarterGui before the game starts, the client script doesn’t run anything, even in StarterPlayerScripts when I tried it, which is why I placed the GUI in ReplicatedStorage initially and then cloned it and put it into PlayerGui later on.
If you can provide me an effective solution which involves putting the GUI and script contains in it inside of StarterGui, please let me know.
By the way, replies may be slow as it is night time in my area. If you need any clarification on the placement of the GUI, please let me know.
Thanks for reading this!