Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How can i make this spawn into to the player gui???

Asked by 7 years ago

I want to make a screen gui clone into the player's gui, but it wont clone. Why is this happening? This script is in a part named Backwall1 and the code is in a local script.

local plr = game.Players.LocalPlayer
script.Parent.Touched:connect(function()
    local help = game.ReplicatedStorage:WaitForChild("Intro")
    help:Clone().Parent = plr.PlayerGui
end)

1 answer

Log in to vote
1
Answered by 7 years ago

Your problem is simple: You're trying to put a LocalScript in a brick.

http://wiki.roblox.com/index.php?title=API:Class/LocalScript

A localscript only works in the locations established in that wiki page.

For a possible solution, you could try using a normal script, like so:

script.Parent.Touched:connect(function(toucher)
    local plr = game:GetService("Players"):GetPlayerFromCharacter(toucher.Parent) or game:GetService("Players"):GetPlayerFromCharacter(toucher.Parent.Parent)
    if plr then
        local help = game:GetService("ReplicatedStorage"):WaitForChild("Intro")
        help:Clone().Parent = plr.PlayerGui
    end
end)
Ad

Answer this question