Hi! So I’m scripting an Accept-Item button for my Cafe but for some reason it doesn’t work.
When the player clicks Yes or No, it tweens away but it doesn’t give him/her the item.
It also doesn’t print yes.
Code:
Server Script
local item = getItem(player.Character)
--Check if the player wanted it or not
local checkIfPlayerWantedIt = game.ReplicatedStorage.Remotes.CheckIfPlayerWantedItem
if player.Name:lower() ~= v.Name:lower() then
local invoke = checkIfPlayerWantedIt:InvokeClient(v)
repeat wait(1) until invoke == "Give" or invoke == false
if invoke == "Give" then
print("Yes")
local clone = item:Clone()
item:Destroy()
clone.Parent = v.Character
player.leaderstats.Points.Value = player.leaderstats.Points.Value +1
end
end
Local Script:
local replicatedStorage = game:GetService("ReplicatedStorage")
local tweenService = game:GetService("TweenService")
local player = game.Players.LocalPlayer
local char = workspace:WaitForChild(player.Name) or workspace[player.Name]
local playerGui = player:WaitForChild("PlayerGui")
local didOrderFrame = playerGui.didOrder.didOrderFrame
local checkIfPlayerWantedIt = game.ReplicatedStorage.Remotes.CheckIfPlayerWantedItem
local yesButton = didOrderFrame.YesButton
local noButton = didOrderFrame.NoButton
--Can't see: {0.346, 0},{-0.3, 0}
--Can see: {0.346, 0},{0.4, 0}
checkIfPlayerWantedIt.OnClientInvoke = function()
--Tween it
didOrderFrame:TweenPosition(UDim2.new(0.346, 0,0.4, 0), Enum.EasingDirection.Out, Enum.EasingStyle.Linear, 0.4)
yesButton.MouseButton1Down:Connect(function()
didOrderFrame:TweenPosition(UDim2.new(0.346, 0,-0.4, 0), Enum.EasingDirection.Out, Enum.EasingStyle.Linear, 0.4)
return "Give"
end)
noButton.MouseButton1Down:Connect(function()
didOrderFrame:TweenPosition(UDim2.new(0.346, 0,-0.4, 0), Enum.EasingDirection.Out, Enum.EasingStyle.Linear, 0.4)
return false
end)
end
Thank you!