Assistance with combining 2 pieces of code

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Assistance with tool giving when gui button pressed.

  2. What is the issue? I’m not that skilled enough, but i’m still learning.

  3. What solutions have you tried so far? I did ask before, but it was closed for a fair reason.


First Image, the code that closes an gui after pressing an button.
image
Image of the code that awards people the tool, which happens when an player joins the server.

I’ve mentioned before that i’m pretty much an beginner with coding, so help is appreciated.

if im right, you want to give a tool with a click of a button (with GUI of course):

roblox has this instance called RemoteEvent, it will send a server signal to the client (player) and vice versa.

so, first make a Remote instance and place where you want, then to the local script, make this:

script.Parent.MouseButton1Click:Connect(function()
   RemoteEvent:FireServer()
end)

And this on the server script

RemoteEvent.onServerEvent:Connect(function(player)--the player is set by default, just write it in the brackets
   tool.Parent = player.BackPack
end)
2 Likes

Yes, I own an roleplay game and there’s an area with an world map, where members of the group get an paint bucket, and once they leave said map using an tp gui, the tool gets taken away from their invertory.

Edit: I’m still clueless with how this works, but i now have an remoteEvent in said gui.
image
I still don’t really get what to do next, but if i can just paste the code you’ve written in the “PlayButton” script, then that would probably help.

With the help of chatGPT, i managed to get the tool giving to work, now i just have to make sure the tool gets taken away once, any assistance?
Edit: I figured it out, but thanks for the help, GabrielG!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.