Before you reply with “You can’t get a guis Absolute Size on a server script.” The script I am using has to be on a server script.
I have a script that gets a TextLabels Absolute Size and sets the text size depending on what the Absolute size is. When printing the value of any axis the value printed is always 0. Is there another way of getting the value without the output printing 0?
I’m guessing you are trying to find something in a Player’s gui, If so it is located in game.Players.[Player Name here].PlayerGui I tested this and it works, but if it doesn’t let me know
Edit: Using this way also gives you more control, including creating and destroying gui instances
But, even if you want to have this on your ServerSide, you can‘t. Guis are LocalSide only, not ServerSide. If you have a Gui on ServerSide, it would like to have a player mouse on the Serverside, and you can‘t this. I mean, a game server can‘t have something that is on your PC, or? Then, why should the Server have a gui from a PC? You can‘t just.
Ok, sorry to say this but, no, why parent a serverscript to something like a gui? If you want or not, you should use a localscript. Why do you want to use a serverscript?
I’m sorry i’m saying this but roblox doesn’t allow that as it is a server script in a client’s gui, it would be better just to run the code on the server using the method i previously said. Roblox just wouldn’t allow that script in the gui to run, try printing something to the output
I am asking why the script has to be on a server script. You not are saying why, you are only saying that this has to be a serverscript, without more details.
For example when a player touches a part the textlabel will only replicate to the client who touched the part ( LOCAL SCRIPT). This is the reason I am using a server script.
You probably want a LocalScript to do your GUI and a single server script (not one in every PlayerGui) to use a remote event with FireAllClients to tell them all to make the TextLabel.
--The Serverscript parented to the Part
local Part = script.Parent
Part.Touched:Connect(function(hit:BasePart) --If the Part is touched
if hit.Parent:FindFirstChildofClass("Humanoid") then --And it was touched from a player
game.ReplicatedStorage.BindableEvent:Fire() --Then fire to the BindableEvent
end
end)
--A ServerScript
game.ReplicatedStorage.BindableEvent.Event:Connect(function() --If the Part was touched from a player
game.ReplicatedStorage.RemoteEvent:FireAllClients() --Then fire this RemoteEvent that says, that the Gui need to be showed up to all players
end)
--The LocalScript located in the StarterGui or a Gui
game.ReplicatedStorage.RemoteEvent.OnClientEvent:Connect(function()
local TextLabel = TheTextLabelLocation
TextLabel.Text = "I am on"
end)
Hope this Code helps out, but yeah, you need a LocalScript, a serverscript is and will ever be a serverscript, so you can‘t get ANYTHING that is located on the Player
Yeah I was thinking of something like that. Although the bindable event is unnecessary I will just put a script in serverscriptservice and send a remote event to the local script.
db = true
script.Parent.Touched:connect(function(part)
if part.Parent:FindFirstChild("Humanoid") ~= nil then
local player = game.Players:GetPlayerFromCharacter(part.Parent)
if player ~= nil then
if db == true then
db = false
--(I don't know how to use a for loop, please rewrite this part)
for plr in game.Players do
label = Instance.New("TextLabel")
label.Text = "Hi"
label.Parent = player.PlayerGui.ScreenGui
end
end
end
end
end)
I don’t know if this will work but it’s worth a try