I’ve made a script which gives an item to a player if he buys it. The thing is everything works with ProximityPrompt but not for the Textbutton. If i click the textbutton then it wont give me the “item”.
As we can see here TextButton | Roblox Creator Documentation. The TextButton doesn’t say who pressed the button or there’s no (function(player) just (function(), So it won’t really work. I never tried using SurfaceUi button function but i think this would work.
• Create a localscript in StarterPlayerScript
• then write your function there
(Path to button).MouseButton1Click:Connect(function()
end)
So i’ve fixed it. Thanks for helping me out btw.
This is the code:
player = game.Players.PlayerAdded:Wait()
game.Workspace.Woodenmenuboard.Menu.SurfaceGui.Frame.teabt.MouseButton1Click:Connect(function()
if player.leaderstats.cash.Value > 4 then
player.leaderstats.cash.Value -= 4
local Tool = game.ServerStorage.ToolsFolder["tea"]:Clone()
Tool.Parent = player.Backpack
end
end)
I think you should use game.Players.PlayerAdded:Connect(function(player) instead of player = game.Players.PlayerAdded:Wait() because it will stop waiting if a player joined or it only works for a single user or the first person to play. Np too!