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

onTouch trying to call out a dialog not working?

local brick = game.workspace.DialogPart

function dialog()
local CustomDialog = Instance.new("ScreenGui")
local Frame = Instance.new("Frame")
local TextLabel = Instance.new("TextLabel")
local ImageLabel = Instance.new("ImageLabel")
CustomDialog.Name = "Custom Dialog"
CustomDialog.Parent = game.StarterGui
Frame.Parent = CustomDialog
Frame.BackgroundColor3 = Color3.new(1, 1, 1)
Frame.Position = UDim2.new(0, 0, 0, 500)
Frame.Size = UDim2.new(0, 1450, 0, 100)
Frame.Style = Enum.FrameStyle.DropShadow
TextLabel.Parent = Frame
TextLabel.BackgroundColor3 = Color3.new(1, 1, 1)
TextLabel.BackgroundTransparency = 1
TextLabel.Position = UDim2.new(0, 600, 0, 15)
TextLabel.Size = UDim2.new(0, 200, 0, 50)
TextLabel.Font = Enum.Font.SciFi
TextLabel.Text = "text"
TextLabel.TextColor3 = Color3.new(1, 1, 1)
TextLabel.TextSize = 64
ImageLabel.Parent = Frame
ImageLabel.BackgroundColor3 = Color3.new(1, 1, 1)
ImageLabel.BackgroundTransparency = 1
ImageLabel.Position = UDim2.new(0.724827588, 0, -2.02999997, 0)
ImageLabel.Size = UDim2.new(0, 300, 0, 300)
ImageLabel.Image = "rbxassetid://560122118"
end

function onTouch()
		dialog()
	end

brick.Touched:connect(onTouch)

Here's what i'm working with. Doesen't do anything, no errors, nothing. Help?

4 comments

0

Why use a function leading to another function leading to another? You could use brick.Touched:connect(dialog) so yeah, it doesn't have to be named "onTouch"

0

is FE on? (filtering enabled)

0

I think it is. Gonna try your (dialog)

0

And yet still not working

1 answer

✓ Accepted answer

A few things your doing wrong, to start with, it would be better to have the gui already, then you can clone it to the player.

Inside the brick you want to put the gui you made and a script (serverscript)

local brick = script.Parent
local gui = script.Parent.Dialog -- Change this if you want
Debounce = true

brick.Touched:connect(function(hit)
	if hit.Parent:FindFirstChild("Humanoid") and Debounce  then -- verify that it is a player and that debounce is true
		Debounce = false
		local char = hit.Parent
		local plr = game.Players:GetPlayerFromCharacter(char)
		
		if not plr.PlayerGui:FindFirstChild("Dialog") then
			local DialogClone = Dialog:Clone()
			DialogClone.Name = "Dialog"
			DialogClone.Parent = plr.PlayerGui
		end
		Debounce = true
	end
end)

If I made a mistake in typing this, ask me xD I hope this works for you, if you want to do this your way though you'll have to work with remote events I guess and change "game.StarterGui" to player.PlayerGui because startergui will only be copied to the playergui on dead. I could try to remake your script but I believe mine would be a lot better, if you have any questions just ask

2 comments

0

Works perfectly! Just had to change local gui to local dialog and everything worked perfectly! Thanks!

0

No problem

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