local part = script.Parent
local gui = game.StarterGui.MorphGUI.MainFrame
part.Touched:Connect(function(part)
gui.Visible = true
gui:Clone()
end)
![]()
![]()
local part = script.Parent
local gui = game.StarterGui.MorphGUI.MainFrame
part.Touched:Connect(function(part)
gui.Visible = true
gui:Clone()
end)
![]()
![]()
I think you’re making the gui in starter gui visible and then just cloning it without a destination.
How should I clone it to the PlayerGUI?
local playerService = game:GetService("Players")
local part = script.Parent
local gui = game.StarterGui.MorphGUI.MainFrame
part.Touched:Connect(function(part)
local guiClone = gui:Clone()
guiClone.Visible = true
local player = playerService:GetPlayerFromCharacter(part.Parent)
guiClone.Parent = player.PlayerGui
end)
I’m sorry I accidentally sent it early so I edited it a bit, didn’t test it in studio, but I think this should work.
I just realised this is a horrible way to do it, I’ll rewrite the code one sec
well first you need to check if the thing that touched “part” is a player
local Part = script.Parent
local GUI = game.StarterGui.MorphGUI.MainFrame
Part.Touched:Connect(function(Hit)
-- Hit would be the player's foot or leg
local Player = game.Players:GetPlayerFromCharacter(Hit.Parent)
local PlayerGui = Player:WaitForChild("PlayerGui")
-- Check if the player already has the gui
if PlayerGui:FindFirstChild(GUI.Name) then return end
local GUIClone = GUI:Clone()
GUIClone.Enabled = true
GUIClone.Parent = PlayerGui
end)
Yeah, also my original script would clone it infinitely
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.