I know it has something to do with cloning to to the StarterGui, but I don't know how. Any help would be appreciated. Here is the start of the script.
function show()
end
script.Parent.ClickDetector.MouseClick:connect(show)
I know it has something to do with cloning to to the StarterGui, but I don't know how. Any help would be appreciated. Here is the start of the script.
function show()
end
script.Parent.ClickDetector.MouseClick:connect(show)
function show()
plr:WaitForChild("PlayerGui").ScreenGui.Frame.Visible = true
end
script.Parent.ClickDetector.MouseClick:connect(function(plr)
show()
end)
You where correct with the function, So to continue on that we need to clone the gui into the players Playergui
function FindClosestPlayer()
dist = 20
pl = ""
for i,v in pairs(game.Players:GetPlayers()) do
if v.Character ~= nil then
if (v.Character.Torso.Position - script.Parent.Position).magnitude < dist then
dist = (v.Character.Torso.Position - script.Parent.Position).magnitude
pl = v.Name
end
end
end
if pl ~= "" then
return pl
end
end
function onClicked()
for i,v in pairs(script:GetChildren()) do
if v:IsA("ScreenGui") then
cl = v:clone()
pl = FindClosestPlayer()
if game.Players:FindFirstChild(pl) ~= nil then
if game.Players:FindFirstChild(pl).PlayerGui:FindFirstChild(v.Name) == nil then
cl.Parent = game.Players:FindFirstChild(pl).PlayerGui
game.Players:FindFirstChild(pl).Character.Humanoid.WalkSpeed = 0
end
end
end
end
end
script.Parent.ClickDetector.MouseClick:connect(onClicked)
Gui must be in the script, and script in the part.
Hope this helps
Just do this:
function Clicked() game.StarterGui.ScreenGui.Frame.Visible = true end script.Parent.MouseButton1Down:connect(Clicked)
-- This is just a basic way of trying to make a Gui show up. If you want to get advanced you would use a loop.
This discussion is preserved as it was. New answers, comments, and votes are closed.
5 comments
error: Script:3 attempt to index global 'hit' (a nil value) Here is what my script looks like function show() guin = control --Gui name if game.Players:findFirstChild(hit.Parent.Name) ~= nil then player = game.Players[hit.Parent.Name] if player.PlayerGui:findFirstChild(guin) == nil then gui = script.Control:clone() gui.Parent = player.PlayerGui
Ok, i fixed it, its a bit longer but, its more effective then my original code
I do like that the character is stuck into position when clicked, but i need it to let them move when the Gui is out of their playerGui.
And, maybe i can also put a walkspeed=16 script inside my close script. the close script is 3 Parents away from the ScreenGui, if that helps you.
Hello??