Speech not appearing

I made a simple script to make speech appear when you touch a part a gui appears but for some reason, it wont work!
Script:

script.Parent.Touched:Connect(function()
	game.Players.LocalPlayer:WaitForChild("PlayerGui").SpeechDarrelIntro.Enabled = true
end)

Please Help!

If this is a LocalScript inside Workspace, it would not work as LocalScripts do not work in Workspace.
If this is a normal script, you can’t use LocalPlayer on a normal script.

Also, when anything touches the part at all, you’re automatically assuming that the part that touched it is a player. I recommend checking if the part that touched it is a player before enabling the ScreenGui.

Its a normal script inside a part, not directly in workspace.

As I mentioned in my previous reply, You can’t use LocalPlayer on a normal script.

Try doing this:

local Players = game:GetService("Players")
 
local part = script.Parent -- Change to wherever your part is located
local function onTouched(part)
	local player = Players:GetPlayerFromCharacter(part.Parent)
	if player then
player.PlayerGui:WaitForChild("SpeechDarrelIntro").Enabled = true
    end
end
part.Touched:Connect(onTouched)
-- Make sure "SpeechDarrelIntro" is a ScreenGui

I wrote this on a phone so I don’t expect it to work…

There is no error on the script or in the output, I added prints to check if the script runs smoothly but nothing is in the output.

Put this script in StarterPlayerScripts:

local Players = game:GetService("Players")

local player = Players.LocalPlayer

local character = player.CharacterAdded:Wait()

character.ABodyPart.Touched:Connect(function(hit)
    if hit.Name = "ThePartYouWantToBeTouch's Name" then
        player.PlayerGui.SpeechDarrelIntro.Enabled = true
    end
end
1 Like