Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Kocking system will not function?

Asked by 2 years ago
Edited 2 years ago

This scripts uses a proximity prompt and is SS

the script

local SoundService = game:GetService("SoundService")

local prompt = script.Parent
local Vent = game.Workspace.MainVent.Vent

local knock = SoundService.Knock
local fall = SoundService.VentFall

local function typewrite(object, text)
    for i = 1, #text,1 do
        object.Text = string.sub(text,1,i)
        wait(0.0227272727) -- how long it takes to type the sentence 
    end
end

prompt.Triggered:Connect(function()
    typewrite(game.StarterGui.Inputs.TextLabel, "You knock on the door, but hear no response.")
    knock:Play()
    wait(2)
    fall:Play()
    Vent.Anchored = false

game.StarterGui.Inputs.TextLabel.Text = ""

end)

for some reason it shows no errors but doesnt work

1 answer

Log in to vote
1
Answered by 2 years ago
Edited 2 years ago

You're using StarterGui instead of PlayerGui. All childrens of StarterGui will automatically be transferred into PlayerGui.

local SoundService = game:GetService("SoundService")

local prompt = script.Parent
local Vent = game.Workspace.MainVent.Vent

local knock = SoundService.Knock
local fall = SoundService.VentFall

local function typewrite(object, text)
    for i = 1, #text,1 do
        object.Text = string.sub(text,1,i)
        wait(0.0227272727) -- how long it takes to type the sentence 
    end
end

prompt.Triggered:Connect(function(plr) -- Tip: Proximity Prompt Triggered can use it's parameter to identify player that triggered the prompt.
    typewrite(plr.PlayerGui.Inputs.TextLabel, "You knock on the door, but hear no response.")
    knock:Play()
    wait(2)
    fall:Play()
    Vent.Anchored = false
end)
Ad

Answer this question