Hey, so I need to perfectly have a GUI on a players head at all times, so i wrote this code and it does work, sadly when the player moves the gui follows him, rather than being on his face. Any ideas?
local Players = game:GetService("Players")
local ServerStorage = game:GetService("ServerStorage")
local RunService = game:GetService("RunService")
local function onCharacterAdded(character)
local ClonedEffect = ServerStorage.Assets.HeadCensorer:Clone()
ClonedEffect.Parent = character
ClonedEffect.CensorGUI.Enabled = true
local Head = character.Head
RunService.Heartbeat:Connect(function()
ClonedEffect.Position = Head.Position
ClonedEffect.CFrame = Head.CFrame
ClonedEffect.Rotation = Head.Rotation
ClonedEffect.Size = Head.Size
end)
end
local function onPlayerAdded(player)
player.CharacterAdded:Connect(onCharacterAdded)
end
Players.PlayerAdded:Connect(onPlayerAdded)```
local Players = game:GetService("Players")
local ServerStorage = game:GetService("ServerStorage")
local RunService = game:GetService("RunService")
local function onCharacterAdded(character)
local ClonedEffect = ServerStorage.Assets.HeadCensorer:Clone()
ClonedEffect.Parent = character.Head
end
local function onPlayerAdded(player)
player.CharacterAdded:Connect(onCharacterAdded)
end
Players.PlayerAdded:Connect(onPlayerAdded)
Why are you doing it on the server?
Heartbeat should be plenty fast, the problem is probably that you’re doing it on the server, there’s never going to be low enough latency for that
If you’re doing it on the server for security then it doesn’t increase security because the server doesn’t render stuff for the client and the client could just delete the GUI on their own client
(You could also just use a billboard gui, I’m sure there’s some reason why you’re not doing that, but just in case you didn’t know)
What exactly is the GUI you’re using? Couldn’t it be turned into a BillBoard GUI and parented to the player’s head? This way you won’t have to worry about moving the position constantly.