Basically, when i step on the yellow brick, an image button shows up inside a scrolling frame. But when i step on it, it doesn’t appear. I set it to visible, so that is not the problem.
Here’s my script:
local buttom = script.ImageButton
local GetBlocks = game.Workspace.GetBlocks
local yeet = game.StarterGui.ScreenGui.MainGui
local e = buttom:Clone()
local function steppedOn(part)
local parent = part.Parent
if game.Players:GetPlayerFromCharacter(parent)then
buttom:Clone().Parent = yeet
end
end
GetBlocks.Touched:Connect(steppedOn)
It looks like you are handling this from the server meaning this sort of thing should be handled from the client. Any visual changes should be handled from the client because it makes the whole process a lot easier. Involving the server is pointless because it doesn’t increase security in anyway.
The reason why this isn’t working is because you aren’t actually parenting the ImageButton to the players Gui but instead to the StarterGui container. Each player gets their own container called PlayerGui that hold all their guis. This can be accessed by doing Player.PlayerGui.
To fix this you should run your code from the client and do all the necessary changes from there. It would also be better if you just made the ImageButton visible instead of cloning it every time. You can see an example of how this works below:
local Block = workspace.Part
local ImageButton = script.Parent.ImageButton
local function OnTouched()
if not ImageButton.Visible then -- Checks if the ImageButton is visible
ImageButton.Visible = true -- Makes the ImageButton visible.
end
end
Block.Touched:Connect(OnTouched) -- Detects when the part is touched
Here is my best attempt at fixing your code:
local buttom = script.ImageButton
local GetBlocks = game.Workspace.GetBlocks
local e = buttom:Clone()
local function steppedOn(part)
local parent = part.Parent
local Player = game.Players:GetPlayerFromCharacter(parent)
local yeet = Player.PlayerGui.ScreenGui.MainGui
if Player then
buttom:Clone().Parent = yeet
end
end
GetBlocks.Touched:Connect(steppedOn)