Hello everyone, I am trying to make a ui appear for only the person that touched a certain part. However, when the player touches that part, the ui appears for everybody.
This is where the localscript is.
This is what is inside the ChefController localscript
local textLabel = script.Parent:WaitForChild("ChefSpeech") -- get the text label
local chef = script.Parent:WaitForChild("Chef") -- get the chef image
local text = textLabel.Text -- get the text that will be displayed on the text label
local isIntroFinished = Instance.new("BoolValue") -- create the boolvalue
isIntroFinished.Parent = script.Parent
isIntroFinished.Value = false
isIntroFinished.Name = "isIntroFinished"
local tomatoCan = game.Workspace:WaitForChild("TomatoCan") -- get the tomato can
local ranOnce = false
local function typewrite(object, text)
chef.Visible = true
textLabel.Visible = true
textLabel.Text = ""
for i = 1, #text, 1 do
object.Text = string.sub(text, 1, i)
wait(0.02)
end
wait(2)
chef.Visible = false
textLabel.Visible = false
print("set isintrofinished to true")
isIntroFinished.Value = true
end
tomatoCan.Touched:Connect(function(touched)
if touched.Parent:FindFirstChild("Humanoid") then
if not ranOnce then
typewrite(textLabel, text)
ranOnce = true
end
end
end)
I am creating a boolvalue from the localscript and activating it, when the intro is finished, because I have another local script that checks if the boolvalue is activated, and makes the UI visible.
This is the contents of the other local script
local isIntroFinished = script.Parent.Parent:WaitForChild("isIntroFinished")
while isIntroFinished.Value == false do
print("isIntrofinished is not finished")
wait()
end
I read these these two threads but I didn’t understand ^
Thanks