hello
I am making a cafe system and once the player has created their drink, the screen goes to the Hand To screen which lists each player and a hand to button for that player.
How would I go about creating a simple hand to script thats gives the player the item that you are holding when you click on their hand to button.
Usage of remote events is the main key here.
1 Like
Firstly, you will need to insert a remote event into the replicated storage named โgiveDrinkโ
Then, put a new script inside of the serverscriptservice, and paste this:
local replicatedStorage = game:GetService("ReplicatedStorage")
local giveDrink = replicatedStorage:WaitForChild("giveDrink")
giveDrink.OnServerEvent:Connect(function(plr, plrToHandTo)
--Hand the drink to the player. You could do this like this:
--[[
local drink = drink
local newDrink = drink:Clone()
]]
end)
Then, insert a script inside of the hand drink text button, and paste this code:
local replicatedStorage = game:GetService("ReplicatedStorage")
local handToButton = script.Parent
local giveDrink = replicatedStorage:WaitForChild("giveDrink") --Create an remote event inside of the ReplicatedStorage named "giveDrink"
handToButton.Activated:Connect(function()
local plrToHandTo = nil --Set this equal to the player to hand the drink to
giveDrink:FireServer(plrToHandTo)
end)
If you have any questions, please let me know
Hope this helped you out a little
2 Likes