I want to make a better version of the roblox classic, "Hint" class by turning it into an open source module script which will soon contain customisable settings like color, font, animation type, animation speed, etc. And that's my idea of I want it to be in the near future.
Basically, how do I make this serversided or something?
I don't know how to do this in a module script because If I use remote events, it's obviously not going to work, server's never handle GUI's and will fail because of that, so only the client can handle GUI's.
Module located at game.StarterGui
local HintModule = {} HintModule.Show = function(player, text, delayTime, everyone) if everyone == true then local guiClone = script:FindFirstChild("ScreenGui"):Clome() -- help how do I make this clone and show text to everybody at the same time?? else if not player then return end if player then script:FindFirstChild("ScreenGui"):Clone().Parent = player.PlayerGui player.PlayerGui:FindFirstChild("ScreenGui").Frame.Visible = true player.PlayerGui:FindFirstChild("ScreenGui").Frame.TextLabel.Text = text task.wait(delayTime) player.PlayerGui:FindFirstChild("ScreenGui"):Destroy() end end end return HintModule
The script that calls the module is a local script in the same parent as the module script is.
What you need to do is create a server script which will send message to all the clients to show a hint, good reason why you don't do that on client is because an exploiter could send signals to the server and to all other clients which would be no good. When client receives a message to show the hint, he will show it, you can change which client to send the hint to. RemoteEvent.FireAllClients is a function that you can use here, an example:
local ReplicatedStorage = game:GetService("ReplicatedStorage") local Players = game:GetService("Players") -- You can create the remote event in edit mode in studio local sendHint = Instance.new("RemoteEvent") sendHint.Name = "SendHint" sendHint.Parent = ReplicatedStorage -- Send a hint to a single player after 5 seconds he joins the game Players.PlayerAdded:Connect(function(player) task.wait(5) sendHint:FireClient(player, "Sadly you have joined the game", 5) end) -- Sends a hint to all players every 5 seconds while true do task.wait(5) sendHint:FireAllClients("Hedreon is noob", 2) end
This script will listen to remote event signals from the server and tell HintModule
to create hints.
local ReplicatedStorage = game:GetService("ReplicatedStorage") local Players = game:GetService("Players") local HintModule = require(script.Parent:WaitForChild("HintModule")) local localPlayer = Players.LocalPlayer ReplicatedStorage.SendHint.OnClientEvent:Connect(function(text, delayTime) HintModule.Show(Players.LocalPlayer, text, delayTime) end)
local HintModule = {} HintModule.Show = function(player, text, delayTime) if not player then return end -- This if statement is useless since on line earlier you "return" from -- the function which stops the function, you can be sure that if -- the function continues running then the player exists --if player then -- Instead of repeating player.PlayerGui:FindFirstChild("ScreenGui") -- just save the gui into a variable local screenGui = script.ScreenGui:Clone() screenGui.Frame.Visible = true screenGui.Frame.TextLabel.Text = text screenGui.Parent = player.PlayerGui task.wait(delayTime) screenGui:Destroy() --end end return HintModule