Hello. I’m currently working on a find the cubes game basically like a scavenger hunt. I am trying to make a pop-up Gui that shows what cube you have found.
The game is single player (1 player server) so a module script is used for keeping track of the player’s cubes found.
The issue is that for some reason, the Gui does not get affected at all, but the remote event that is fired from the server to the client does not break or error. The Gui just simply won’t turn visible or get affected in any way.
I’ve tried to make the entire ScreenGui enable and disable and saw if that would work, but it still didn’t affect the Gui. I tried to make a frame of a different ScreenGui enable and disable and it worked with a different local script, but it didn’t work in the OnClientEvent function in the actual local script below. I looked in the Developer Hub but I couldn’t find any solution related to my problem.
Here is the local script named Message:
--Script is the Receiver of Remote Event
--Services
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local StarterGui = game:GetService("StarterGui")
--Variables
local FoundCubeRemoteEvent = ReplicatedStorage:WaitForChild("FoundCubeRemoteEvent")
local FoundCubeGui = StarterGui:WaitForChild("ScreenGui")
local FoundCubeFrame = FoundCubeGui:WaitForChild("FoundCubeFrame")
local CubeViewportFrame = FoundCubeFrame:WaitForChild("CubeViewportFrame")
--Tween Info
--local tweenInfo = 0
--Listener of Remote Event
FoundCubeRemoteEvent.OnClientEvent:Connect(function(cubeObject)
--Setting Frame visibility to true
FoundCubeFrame.Visible = true
print(FoundCubeFrame.Visible)
FoundCubeFrame:WaitForChild("FoundCubeLabel").Text = cubeObject.Name .. "!"
print(FoundCubeFrame:WaitForChild("FoundCubeLabel").Text)
--Sets the color property of the FoundCubeLabel to the color of the rarity
if cubeObject:WaitForChild("Rarity").Value == "Common" then
FoundCubeFrame:WaitForChild("FoundCubeLabel").TextColor3 = Color3.fromRGB(97, 97, 97)
elseif cubeObject:WaitForChild("Rarity") == "Uncommon" then
FoundCubeFrame:WaitForChild("FoundCubeLabel").TextColor3 = Color3.fromRGB(47, 180, 40)
elseif cubeObject:WaitForChild("Rarity") == "Rare" then
FoundCubeFrame:WaitForChild("FoundCubeLabel").TextColor3 = Color3.fromRGB(25, 86, 255)
elseif cubeObject:WaitForChild("Rarity") == "Epic" then
FoundCubeFrame:WaitForChild("FoundCubeLabel").TextColor3 = Color3.fromRGB(109, 25, 255)
end --Expand when more rarities!
--ViewPort
CubeViewportFrame:ClearAllChildren() --Removing previous cubes and cameras from the cube viewport frame to refresh it
local cubeClone = cubeObject:Clone()
cubeClone.Parent = CubeViewportFrame
local camera = Instance.new("Camera")
camera.Parent = CubeViewportFrame
CubeViewportFrame.CurrentCamera = camera
camera.CFrame = cubeClone.CFrame * CFrame.new(0, 0, cubeClone.Size.z * 1.5)
--Tween In
--Tween Out
wait(5)
--Setting Frame visibility to false
FoundCubeFrame.Visible = false
print(FoundCubeFrame.Visible)
end)
Here is the Module Script named CubesModule:
local Module = {
CubeList = {},
FoundCubes = {},
CubeCount = 0
}
return Module
Here is the server-sided script named CubeDetectionScript
(This script is inside every cube that you can collect):
local CubesModule = require(game:GetService("ServerScriptService").CubesModule)
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local FoundCubeRemoteEvent = ReplicatedStorage:WaitForChild("FoundCubeRemoteEvent")
local players = game:GetService("Players")
local cube = script.Parent
foundCubes = CubesModule.FoundCubes
--When the cube is found by player
cube.Touched:Connect(function(touch)
if touch.Parent:FindFirstChild("Humanoid") then
local char = touch.Parent
local plr = players:GetPlayerFromCharacter(char)
--Checks if already found
local check
for i, v in pairs(CubesModule.FoundCubes) do
if v == cube.Name then
check = true
end
end
--If cube not found yet then this cube is found
if check ~= true then
print(tostring(plr) .. " found " .. cube.Name)
table.insert(foundCubes, cube.Name)
CubesModule.CubeCount = #(CubesModule.FoundCubes)
plr:WaitForChild("leaderstats"):WaitForChild("Cubes").Value = CubesModule.CubeCount
print(CubesModule.CubeCount)
print(plr.leaderstats.Cubes.Value)
FoundCubeRemoteEvent:FireClient(plr, cube)
end
end
end)
Here is the Main Server-Sided Script named MainScript:
--Modules
CubesModule = require(game:GetService("ServerScriptService").CubesModule)
--Leaderstats
game.Players.PlayerAdded:Connect(function(plr)
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = plr
local plrFoundCubes = Instance.new("IntValue")
plrFoundCubes.Name = "Cubes"
plrFoundCubes.Parent = leaderstats
plrFoundCubes.Value = CubesModule.CubeCount --Use module to set value and maybe use remote events/functions, and will be saved and loaded with datastore
end)
--Services
local ReplicatedStorage = game:GetService("ReplicatedStorage")
--Variables
local CubeDetectionScript = game.ServerStorage.ScriptsStorage.CubeDetectionScript
local CubeList = {}
for i, v in pairs(game.Workspace.CubeStorageWorkspace:GetChildren()) do
DetectionScript = CubeDetectionScript:Clone()
DetectionScript.Parent = v
DetectionScript.Enabled = true
name = v.Name
CubeList[i] = name
end
CubesModule.CubeList = CubeList
CubesModule.CubeCount = #(CubesModule.FoundCubes)
while true do
wait(5)
print(CubesModule.FoundCubes)
end
Here is the Gui:
Thank you all