Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Why the error? I cannot see whats wrong, and the ("PlayerGui") Works

but when I put ("PlayerGui") on line 15 the ( has a error, the error says:

Workspace.Part.Script:15: Ambiguous syntax: this looks like an argument list for a function call, but could also be a start of new statement Im trying to make a gui visible when the part is touched. and im trying to put some text on stuff .-.

The script in the part;


local part = script.Parent
part.Touched:Connect(
    function(hit)
        hit.Parent.HumanoidRootPart.Anchored = true
        local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
        if plr then
            plr:FindFirstChild("PlayerGui").Quest1.Frame.Visible = true
                plr:FindFirstChild("PlayerGui").Quest1.Frame.Visible = true
                wait(0.1)
                plr:FindFirstChild("PlayerGui").Quest1.Frame:WaitForChild("TextLabel").Visible = true
                wait(0.1)
                plr:FindFirstChild("PlayerGui").Quest1.Frame.TextLabel.Text =
                    ("Hey, can you find my teddy bear? I lost it *is sad*")
                           wait(1)
            ("PlayerGui").Quest1.Frame.Where is it?.Visible = true
            ("PlayerGui").Quest1.Frame.Goodbye!.Visible = true
            wait(0.1)
            ("PlayerGui").Quest1.Frame.Where is it?.Text = ("Where is it?")
            ("PlayerGui").Quest1.Frame.Goodbye!.Text = ("Goodbye!")
            end
        end
)
part.TouchEnded:Connect(
    function(hit)
        hit.Parent.HumanoidRootPart.Anchored = true
        local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
        plr:FindFirstChild("PlayerGui").Quest1.Frame.Visible = false
    end
)


2 answers

✓ Accepted answer

Please define what PlayerGui is next time, but I'll just do plr.PlayerGui

Also to fix the errort, add [""]

local part = script.Parent
part.Touched:Connect(
    function(hit)
        hit.Parent.HumanoidRootPart.Anchored = true
        local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
        if plr then
            plr.PlayerGui.Quest1.Frame.Visible = true
            plr.PlayerGui.Quest1.Frame.Visible = true
            wait(0.1)
            plr.PlayerGui.Quest1.Frame:WaitForChild("TextLabel").Visible = true
            wait(0.1)
            plr.PlayerGui.Quest1.Frame.TextLabel.Text = ("Hey, can you find my teddy bear? I lost it *is sad*")
            wait(1)
            plr.PlayerGui.Quest1.Frame["Where is it?"].Visible = true
            plr.PlayerGui.Quest1.Frame["Goodbye!"].Visible = true
            wait(0.1)
            plr.PlayerGui.Quest1.Frame["Where is it?"].Text = ("Where is it?")
            plr.PlayerGui.Quest1.Frame["Goodbye!"].Text = ("Goodbye!")
        end
    end
)
part.TouchEnded:Connect(
    function(hit)
        hit.Parent.HumanoidRootPart.Anchored = true
        local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
        plr.PlayerGui.Quest1.Frame.Visible = false
    end
)


Your trying to define a string as an instance. ("PlayerGui") will not work and instead you could set a variable named PlayerGui to the actual PlayerGui. You also can't put spaces in the middle of a line or special characters like that. Instead do this for line 15 (and other lines) after you define the variable "PlayerGui."

PlayerGui.Quest1.Frame['Where is it?'].Visible = true

This discussion is preserved as it was. New answers, comments, and votes are closed.