Trying to put a gui into PlayerGui

i’m trying to put a gui into the player’s PlayerGui, but the function i’m using is Touched which does an error because playergui isn’t a part of the player model. instead, i tried to go about using local player, but that doesn’t work either because i’m using a serversided script. how would i fix this?

local TweenService = game:GetService("TweenService")
local seconds = 1.2
local f = script.Parent.Parent.WeezerChase

local goal = {}
goal.Position = Vector3.new(192.11, 6.69, -22.195)

local tweenInfo = TweenInfo.new(seconds)

local tween = TweenService:Create(f, tweenInfo, goal)


d = script.Parent
e = script.Parent.Parent.WeezerChase.Decal
plr = game.Players.LocalPlayer


d.Touched:Connect(function(hit)
	if hit.Parent:FindFirstChild("Humanoid") then
		e.Transparency = 0
		wait(5)
		tween:Play()
		wait(2)
		for i,v in pairs(script:GetChildren()) do
			if v.Name == "Ending3" then
				local c = v:Clone()
				c.Parent = plr.PlayerGui
				local frame = plr.PlayerGui.Ending3.Frame
				wait(2)
				frame.TextLabel.TextTransparency = 0
				wait(1)
				frame.Tunnel.TextTransparency = 0
				wait(2)
				frame.D.TextTransparency = 0
				wait(5)
				hit:Kick("END")
			end
		end
	end
end)
1 Like

PlayerGUI is always a child of the Player, not the Player’s Model. You can achieve what your expecting by using :GetPlayerFromCharacter.

local TweenService = game:GetService("TweenService")
local seconds = 1.2
local f = script.Parent.Parent.WeezerChase

local goal = {}
goal.Position = Vector3.new(192.11, 6.69, -22.195)

local tweenInfo = TweenInfo.new(seconds)

local tween = TweenService:Create(f, tweenInfo, goal)


d = script.Parent
e = script.Parent.Parent.WeezerChase.Decal


d.Touched:Connect(function(hit)
	if hit.Parent:FindFirstChild("Humanoid") then
		local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
		e.Transparency = 0
		wait(5)
		tween:Play()
		wait(2)
		for i,v in pairs(script:GetChildren()) do
			if v.Name == "Ending3" then

				local c = v:Clone()
				c.Parent = plr.PlayerGui
				local frame = plr.PlayerGui.Ending3.Frame
				wait(2)
				frame.TextLabel.TextTransparency = 0
				wait(1)
				frame.Tunnel.TextTransparency = 0
				wait(2)
				frame.D.TextTransparency = 0
				wait(5)
				hit:Kick("END")
			end
		end
	end
end)

This should work, but I have not tested it yet, so reply if there is any errors

2 Likes

I could be wrong here, but I think you need to do

plr.PlayerGui.ScreenGui.......
1 Like

That wont work. You cant obtain a localplayer on serverside + they were right with plr.PlayerGui, they just were getting the player in the wrong way

1 Like

oh, thought it was clientside, mb (remind me to read everything next time)

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.