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

How do I fix this script? I am trying to make a script that if you touch this block you get the GUI.

Asked by 9 years ago

Please provide more explanation in your question. If you explain exactly what you are trying to accomplish, it will be much easier to answer your question correctly.

I want this script to work on a person. I am trying to make a script that if you touch this block you get the GUI. This is in a part.

local part = script.Parent
local function steppedOn(part)
    local parent = part.Parent
    if game.Players:GetPlayerFromCharacter(parent) then
        local testing = parent.Name
        local test = game.Players.testing
        local c = game.Workspace.Sounds:Clone()
        c.Parent = test.PlayerGui
    end
end

part.Touched:connect (steppedOn)

1 answer

Log in to vote
0
Answered by
xuefei123 214 Moderation Voter
9 years ago

Its simple, so this script is the child of the part,

local gui = script.gui--change to the location of the gui
function touch(hit)
    if hit.Parent then
        local playergui = hit:FindFirstChild("PlayerGui")
            local newgui = gui:Clone()--clones the gui
                newgui.Parent = playergui

                print("Complete!")--remove this if you want
end
end

script.Parent.Touched:connect(hit)-- connects the function

so that was simple..

but this is what was wrong with your script

local part = script.Parent
local function steppedOn(part)
    local parent = part.Parent--not needed
    if game.Players:GetPlayerFromCharacter(parent) then--not needed
        local testing = parent.Name--parent should be part
        local test = game.Players.testing
        local c = game.Workspace.Sounds:Clone()--sounds? i thought it was a gui
        c.Parent = test.PlayerGui--again should be part
    end
end

part.Touched:connect (steppedOn)

No Problem.

Ad

Answer this question