Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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

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

2 comments

0

I would put this in a server script correct?

0

Yes I already determined the key, but thanks this helps

This discussion is preserved as it was. New answers, comments, and votes are closed.