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

I cant see whats wrong? Why is there an error I really cant see whats wrong? [PLEASE HELP]

The error: Workspace.Part.Script:11: Ambiguous syntax: this looks like an argument list for a function call, but could also be a start of new statement

The script in the part:


local part = script.Parent
part.Touched:Connect(
	    function(hit)
		workspace.N_10BY.HumanoidRootPart.Anchored = true
        local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
        if plr then
            plr:WaitForChild("PlayerGui").Quest1.Frame.Visible = true
            if part.Touched == false then
				                ("PlayerGui").Quest1.Frame.Visible = true
				wait(0.1)
				("PlayerGui").Quest1.Frame.TextButton.Visible = true
				wait(0.1)
				("PlayerGui").Quest1.Frame.TextButton.Text = ("Hey, can you find my teddy bear? I lost it :(")
				wait(5)
				
            end
        end
    end
)
part.TouchEnded:Connect(
	    function(hit)
		workspace.N_10BY.HumanoidRootPart.Anchored = true
        local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
        plr:WaitForChild("PlayerGui").Quest1.Frame.Visible = false
    end
)


2 answers

local playergui = plr.PlayerGui

--replace ("playergui") with playergui

it'll probably work and will fix your error

The main problem inside of your code is this part:

("PlayerGui").Quest1.Frame.Visible = true
wait(0.1)
("PlayerGui").Quest1.Frame.TextButton.Visible = true
wait(0.1)
("PlayerGui").Quest1.Frame.TextButton.Text = ("Hey, can you find my teddy bear? I lost it :(")

You can't really just slap ("PlayerGui") into your code, as the game doesn't know what it is. Instead, try defining what it is first through a variable and then using a variable instead.

Put this after "local plr = game.Players:GetPlayerFromCharacter(hit.Parent)" in your code:

local PlayerGUI = plr:WaitForChild("PlayerGui")

Here's the edited version of your script:

local part = script.Parent
part.Touched:Connect(
	function(hit)
		workspace.N_10BY.HumanoidRootPart.Anchored = true
		local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
		local PlayerGUI = plr:WaitForChild("PlayerGUI")
		if plr then
			plr:WaitForChild("PlayerGui").Quest1.Frame.Visible = true
			if part.Touched == false then
				PlayerGUI.Quest1.Frame.Visible = true
				wait(0.1)
				PlayerGUI.Quest1.Frame.TextButton.Visible = true
				wait(0.1)
				PlayerGUI.Quest1.Frame.TextButton.Text = ("Hey, can you find my teddy bear? I lost it :(")
				wait(5)
				end
			end
		end
	)
	part.TouchEnded:Connect(
	function(hit)
	workspace.N_10BY.HumanoidRootPart.Anchored = true
	local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
	plr:WaitForChild("PlayerGui").Quest1.Frame.Visible = false
	end
)

Also, please, PLEASE indent your code correctly in the future.

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