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)
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