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

Best way to make Sign usign ("UserInputService")?

Asked by 4 years ago
Edited 4 years ago

I'm trying to create undertale sign, that after pressing "z", will show you gui with message, but I don't know what's the best way to make it. Here's my script:

--Normal Script
local UIS = game:GetService("UserInputService")

UIS.InputBegan:connect(function(Input)
    local MouseInput = Input.UserInputType
    local KeyCode = Input.KeyCode 

    if KeyCode == Enum.KeyCode.Z then
        local player = game.Players.LocalPlayer
        if player.PlayerGui:FindFirstChild("TextGui") then return end                   
            if player.Sign.Value == true then
                local r = game.ReplicatedStorage.TextGui:Clone()
                r.Parent = player.PlayerGui
            end
    end
end)



--Sign is BoolValue
script.Parent.Touched:Connect(function(hit)
    local player = hit.Parent
    local player2 = game.Players:GetPlayerFromCharacter(hit.Parent)
    if player and player2 then
        player.HumanoidRootPart.Anchored = true
        player2.Sign.Value = true
    end
end)

script.Parent.TouchEnded:Connect(function(hit)
    local player = hit.Parent
    local player2 = game.Players:GetPlayerFromCharacter(hit.Parent)
    if player and player2 then
        player2.Sign.Value = false
        if player2.PlayerGui:FindFirstChild("TextGui") then
            player2.PlayerGui.TextGui:Remove()
        end
    end
end)
0
Is it in a local script? CaptainAlien132 225 — 4y

1 answer

Log in to vote
-1
Answered by 4 years ago

That seems like it should work perfectly fine.

Ad

Answer this question