so basically, im trying to get a module function work when a specific part i made is touched, but when i touch it doesnt work. how do i fix this?
the text lines from my module
local Players = game:GetService("Players")
local client = Players.LocalPlayer
local ChapterText = {}
function ChapterText.ClassicChapterText(Text: string)
local ScreenGui = Instance.new("ScreenGui")
ScreenGui.Name = "ChapterEntrance"
local CText = Instance.new("TextLabel")
CText.Name = "ChapterName"
ScreenGui.Parent = game.StarterGui
CText.Parent = ScreenGui
CText.Text = Text
end
return ChapterText
the part touch script
local Players = game:GetService("Players")
local text = require(game.ReplicatedStorage.ChapterTextModule)
script.Parent.Touched:Connect(function(part)
-- make sure the part still exists
if not part.Parent then return end
-- make sure it's a humanoid
local h = part.Parent:FindFirstChild("Humanoid")
local player = Players:GetPlayerFromCharacter(part.Parent)
print(player)
if not h then return end
text.ClassicChapterText("Chapter #dsad")
script.Parent:Destroy()
end)