i’m making an script which will look for player using string value and then find PlayerGui inside it.
and yes i’ve seen an post similiar to this but its not the right solution
script:
function onYes()
if game.Players:WaitForChild(script.Parent.Parent.barista.Value):IsA("Player") then
game.Players:WaitForChild(script.Parent.Parent.barista.Value).PlayerGui.GiveSystem.AddPoint:FireServer(script.Parent.Parent.barista.Value)
-- item.Parent = game.Players.LocalPlayer.Backpack
script.Parent:TweenPosition(UDim2.new(0.5, -200,0,-121))
wait(1)
script.Parent:Destroy()
end
end
Either way, you might want to spread out your WaitForChilds like so:
function onYes()
if Players:FindFirstChild(script.Parent.Parent.barista.Value) then
local Player = Players[script.Parent.Parent.barista.Value]
local PlayerGui = Player:WaitForChild("PlayerGui")
local GiveSystem = PlayerGui:WaitForChild("GiveSystem")
local AddPoint = GiveSystem:WaitForChild("AddPoint")
AddPoint:FireServer() -- Player is sent automatically
script.Parent:TweenPosition(UDim2.new(0.5, -200,0,-121))
wait(1)
script.Parent:Destroy()
end
end
Try adding a warning to let you know what the problem is:
function onYes()
if Players:FindFirstChild(script.Parent.Parent.barista.Value) then
local Player = Players[script.Parent.Parent.barista.Value]
local PlayerGui = Player:WaitForChild("PlayerGui")
local GiveSystem = PlayerGui:WaitForChild("GiveSystem")
local AddPoint = GiveSystem:WaitForChild("AddPoint")
AddPoint:FireServer() -- Player is sent automatically
script.Parent:TweenPosition(UDim2.new(0.5, -200,0,-121))
wait(1)
script.Parent:Destroy()
else
warn(script.Parent.Parent.barista.Value, "was not found in Players")
end
end
function onYes()
if Players:FindFirstChild(script.Parent.Parent.barista.Value) then
local Barista = Players[script.Parent.Parent.barista.Value]
local PlayerGui = Barista:WaitForChild("PlayerGui")
local GiveSystem = PlayerGui:WaitForChild("GiveSystem")
local AddPoint = GiveSystem:WaitForChild("AddPoint")
print("Barista is =", Barista)
AddPoint:FireServer(Barista) -- Client is sent automatically
script.Parent:TweenPosition(UDim2.new(0.5, -200,0,-121))
wait(1)
script.Parent:Destroy()
else
warn(script.Parent.Parent.barista.Value, "was not found in Players")
end
end
Then add a print statement immediately after the function name:
function onYes()
print("OnYes Called")
if Players:FindFirstChild(script.Parent.Parent.barista.Value) then
local Barista = Players[script.Parent.Parent.barista.Value]
local PlayerGui = Barista:WaitForChild("PlayerGui")
local GiveSystem = PlayerGui:WaitForChild("GiveSystem")
local AddPoint = GiveSystem:WaitForChild("AddPoint")
print("Barista is =", Barista)
AddPoint:FireServer(Barista) -- Client is sent automatically
script.Parent:TweenPosition(UDim2.new(0.5, -200,0,-121))
wait(1)
script.Parent:Destroy()
else
warn(script.Parent.Parent.barista.Value, "was not found in Players")
end
end