Drink = game.Lighting.Water
script.Parent.MouseButton1Down:connect(function(plr)
nDrink = Drink:Clone()
nDrink.Parent = plr.Backpack
end)
What's wrong with this???
Drink = game.Lighting.Water
script.Parent.MouseButton1Down:connect(function(plr)
nDrink = Drink:Clone()
nDrink.Parent = plr.Backpack
end)
What's wrong with this???
The problem here is MouseButton1Down does not return a player, it returns an X and Y value.
A way to go about what you want is using a LocalScript inside the StarterGui that handles the ScreenGui instead, and using the LocalPlayer to get the player value.
Hope this helps!
If you need some help with the method above, comment and I'll write you up something
-- Inside a Localscript placed within StarterPlayerScripts
local plr = game.Players.LocalPlayer
local gui = game.Workspace.ToolTest.SurfaceGui
local button = gui.Frame.TextButton
-- Replaced Water for testing purposes
-- Also NEVER put tools into Lighting. ReplicatedStorage or ServerStorage is more recommended.
Drink = game.ReplicatedStorage.GravityCoil
button.MouseButton1Click:Connect(function()
local nDrink = Drink:Clone()
nDrink.Parent = plr.Backpack
end)
Hope this helps!
This discussion is preserved as it was. New answers, comments, and votes are closed.
2 comments
Btw it's a surface gui
Protip: NEVER store anything important into Lighting (or any tools at all). ServerStorage exists for a reason.