Script not working

Hi so I want to make a startergui visible when a part is touched. This is my script but it does not work when the part is touched.

script.Parent.Touched:Connect(function(hit)
	if hit and hit.Parent and hit.Parent:FindFirstChild("Humanoid") then
		script.Parent.CutsceneModulekreek:Clone().Parent = game.ReplicatedStorage.CodesOtaku
		game.Workspace.Music.Playing = false

		wait(3)
		game.StarterGui.Text6.ImageLabel.Visible = true
		game.StarterGui.Text6.TextLabel.Visible = true
		wait(5)
		game.StarterGui.Text6.ImageLabel.Visible = false
		game.StarterGui.Text6.TextLabel.Visible = false
	end
end)
4 Likes

You need to do it from the player, example:

local Players = game:GetService("Players")

local part = script.Parent
local function onTouched(part)
	local player = Players:GetPlayerFromCharacter(part.Parent)
	if not player then return end
	player.PlayerGui.ScreenGui.Frame.Visible = true
end
part.Touched:Connect(onTouched)

Apologies for not fixing your script but I’m terrible with working with a script when it’s not in the workspace

1 Like

I have the script in the workspace inside a part.

1 Like

Your going to have to screenshot the explorer so I can help you

This is the workspace. What I need is when the TpPart is touched I want the ImageLabel and Text Label to become visible.

local Players = game:GetService("Players")

script.Parent.Touched:Connect(function(hit)
	local player = Players:GetPlayerFromCharacter(hit.Parent)
	if not player then return end
	player.PlayerGui.Text6.ImageLabel.Visible = true
	player.PlayerGui.Text6.TextLabel.Visible = true
end)
3 Likes

Thank you! You are so kind for helping me : D

2 Likes