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

How would I make clicking a GUI give you a weapon?

Asked by
ym5a 52
3 years ago

Don't worry about the GUI part I have that figured out (with a passcode too) I just need to know how to make it give a weapon

the localscript:

local textbox = script.Parent:WaitForChild("TextBox")
local button = script.Parent:WaitForChild("TextButton")

button.MouseButton1Click:Connect(function()
    local result = game.ReplicatedStorage.RemoteFunction:InvokeServer(textbox.Text)
    if result == "right" then
        button.Text = "you did it yay"
        wait(2)
        button.Text = "Gun"
    else
        button.Text = "YOU FAILED I HATE YOU"
        wait(2)
        button.Text = "Gun"
    end
end)

1 answer

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

This isn't a request site but I'm not going to skip out on helping you.

You have to set the OnServerInvoke for your RemoteFunction to be able to determine the rightfulness of the key.

function RemoteFunction.OnServerInvoke(Player, Key)
    local Tool = nil -- Replace nil with path to your tool.
    if Key == "" then
        Tool:Clone().Parent = Player:FindFirstChildWhichIsA("Backpack")
        return "right"
    end
    return "wrong"
end
0
I would put this in a server script correct? ym5a 52 — 3y
0
Yes I already determined the key, but thanks this helps ym5a 52 — 3y
Ad

Answer this question