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

Help on debugging the dialogue script?

i'm making some dialogue for my horror game, but i can't seem to find the error, any help?

the error says that MainDoorAnnouncement2 is not a valid member of Workspace "Workspace"

--the script idk

local TextLabel = script.Parent
local Text

function SoundEffect()
	local Sound = Instance.new('Sound',workspace)
	Sound.Name = 'TextSound'
	Sound.SoundId = "http://www.roblox.com/asset/?id=3333976425"
	Sound.PlaybackSpeed = 1
	Sound.Volume = 1
	Sound:Play()
	coroutine.resume(coroutine.create(function()
		wait(1)
		Sound:Destroy()
	end))
end

function setText(word)
	Text = word
	for i = 1, #Text do
		TextLabel.Text = string.sub(Text, 1, i)
		SoundEffect()
		TextLabel.TextColor3 = Color3.fromRGB(255,255,255)
		wait(0.1)
	end
end

setText('...Wh...Shelter?')
wait(5)
setText('I`ll try getting there...')
wait(5)
workspace.haha.Part1:Destroy()
workspace.haha.Part2:Destroy()
workspace.haha.Part3:Destroy()
workspace.haha.Part4:Destroy()
setText("Let's go. Seems to be up ahead, if I keep going straight I'll reach it.")

game.Workspace.MainDoorAnnouncement.Touched:Connect(function()
	workspace.MainDoorAnnouncement:Destroy()
	setText("Darn, It's locked!")
	game.ReplicatedStorage.Knife.Parent = workspace
	game.ReplicatedStorage.MainDoorAnnouncement2.Parent = workspace
	wait(2.5)
	setText("I should probably look for some clues, maybe the tree?")
end)

game.Workspace.MainDoorAnnouncement2.Touched:Connect(function() --THE LINE OF THE ERROR
	setText("What the...A knife? I feel like I'm being watched. I should check that door again just to be sure...")
	workspace.Door.Parent = game.ReplicatedStorage
	workspace.MainDoorAnnouncement2:Destroy()
	game.ReplicatedStorage.Door2.Parent = game.Workspace
	game.ReplicatedStorage.MainDoorAnnouncement3.Parent = workspace
end)

1 answer

✓ Accepted answer
game.Workspace.MainDoorAnnouncement.Touched:Wait()
    workspace.MainDoorAnnouncement:Destroy()
    setText("Darn, It's locked!")
    game.ReplicatedStorage.Knife.Parent = workspace
    game.ReplicatedStorage.MainDoorAnnouncement2.Parent = workspace
    wait(2.5)
    setText("I should probably look for some clues, maybe the tree?")

game.Workspace.MainDoorAnnouncement2.Touched:Wait()
    setText("What the...A knife? I feel like I'm being watched. I should check that door again just to be sure...")
    workspace.Door.Parent = game.ReplicatedStorage
    workspace.MainDoorAnnouncement2:Destroy()
    game.ReplicatedStorage.Door2.Parent = game.Workspace
    game.ReplicatedStorage.MainDoorAnnouncement3.Parent = workspace


1 comment

0

instead of game.Workspace use workspace and game:GetService("ReplicatedStorage") to make it better

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