Hello, the wonderful scripters. (o゚v゚)ノ
I’m working on a touch triggered cutscene for a secret ending when player touches teddy. I don’t have a problem with my cutscene, it plays when player touches the teddy.
I made a screengui and I want that it will be enabled when player touched the script.Parent.
It doesn’t wait the trigger and makes it enabled
I know, my script is wrong. Just I don’t how can I trigger the gui with a function.
Script is parented to handle. It is not a local script.
Script:
local cutsceneText = game.StarterGui.ScreenGui3
local function onTouch()
cutsceneText.Enabled = true
end
script.Parent.Touched:Connect(onTouch)
Rules:
•No making fun of me because of I can script the whole cutscene script but can’t script this easy script.
•Don’t yell at me if you explain and I don’t understand. Stay calm against my brain that doesn’t exist.
•Respect each other (●’◡’●)
I can give more information if you ask for it(≧∇≦)ノ
The script.Parent is touched by another part besides a player so the function enables ScreenGui before any player activates the trigger. Also StarterGui is not a part of the current GUI of a player. Considering those two mistakes, you need this script instead:
local function onTouch(part)
if part.Parent:FindFirstChildOfClass("Humanoid") ~= nil then
game.Players:GetPlayerFromCharacter(part.Parent).PlayerGui.ScreenGui3.Enabled = true
end
end
script.Parent.Touched:Connect(onTouch)
Hey, it’s because you aren’t checking if a humanoid has touched the part. Instead it is touched by another part besides the player. I have edited your script and this should work:
local function OnTouch(Part)
if Part.Parent:FindFirstChildOfClass("Humanoid") ~= nil then
game.Players:GetPlayerFromCharacter(Part.Parent).PlayerGui.ScreenGui3.Enabled = true
end
end
script.Parent.Touched:Connect(OnTouch)
Thank you!
I got it, touched event checks every touch. To find if player touched it, checks humanoid isn’t nil.
Added a function to enable it correctly.
Thanks a lot again:D