Hi, I have a problem with this script I made. I’m working on a horror game and everything goes well until you equip the flashlight, after the flashlight is equipped the script stops working and doesn’t do what it’s supposed to do. Please help!
local lp = game:GetService("Players").LocalPlayer
local playbtn = lp.PlayerGui:WaitForChild("ScreenGui1"):WaitForChild("BG"):WaitForChild("PlayButton")tool = game.Workspace.Flashlight
local handle = tool:WaitForChild("Handle")
local cancolide = game.Workspace.cancolide2
local typingso = game.ReplicatedStorage.Typing
local sound = game.Workspace.clicksound
local touch = game.Workspace.touchpart
local back = game.Workspace.backpart
local mons = game.Workspace.monster
local pointlight = game.Workspace.point.PointLight
local jump = game.Workspace.jump2
local debounce = false
local function typewrite(object, text: string, delay: number)
object.Text = text
local i: number = 0
for _ in utf8.graphemes(text) do
i += 1
object.MaxVisibleGraphemes = i
typingso:Play()
task.wait(delay)
end
end
playbtn.MouseButton1Click:Connect(function()
wait(3)
script.Parent.Text = "Chapter 1 - Maybe it's all an illusion?"
wait(3)
typewrite(script.Parent, 'This house is really dark.', 0.04)
wait(3)
typewrite(script.Parent, 'I need to find a flashlight.', 0.04)
wait(3)
script.Parent.TextColor3 = Color3.new(1, 0, 0)
script.Parent.Text = "Objective: Find a flashlight"
cancolide.CanCollide = false
end)
touch.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
if not debounce then
debounce = true
print("working")
script.Parent.TextColor3 = Color3.new(1, 1, 1)
typewrite(script.Parent, "I can't find it", 0.04)
wait(3)
typewrite(script.Parent, "I think it's not here!", 0.04)
wait(3)
typewrite(script.Parent, "Maybe I left it in the kitchen.", 0.04)
wait(3)
script.Parent.TextColor3 = Color3.new(1, 0, 0)
script.Parent.Text = "Objective: Go back"
back.Size = Vector3.new(3, 30, 30)
end
end
end)
tool.Equipped:Connect(function()
if not debounce then
debounce = true
sound:Play()
handle.SpotLight.Enabled = true
wait(0.1)
script.Parent.TextColor3 = Color3.new(1, 1, 1)
typewrite(script.Parent, 'I found it!', 0.04)
wait(3)
typewrite(script.Parent, 'Hmm.. I want to watch some TV.', 0.04)
wait(3)
script.Parent.TextColor3 = Color3.new(1, 0, 0)
script.Parent.Text = "Objective: Watch TV."
wait(40)
script.Parent.TextColor3 = Color3.new(1, 1, 1)
typewrite(script.Parent, 'Oh no!', 0.04)
wait(3)
typewrite(script.Parent, 'I have to get my phone from my room!', 0.04)
wait(3)
script.Parent.TextColor3 = Color3.new(1, 0, 0)
script.Parent.Text = "Objective: Open the door."
end
end)