yes thanks. sorry it’s so messy
It doesn’t work because of the ‘script.Parent.MouseButton1Click:Connect(function()’ in the playeradded function
script.Parent.MouseButton1Click:Connect(function(player)
DESTROYY()
for i,v in pairs(player.PlayerGui.PetInv.TextButton.Frame.ScrollingFrame.Frames:GetChildren()) do
if v.Name ~= "UI" then
if (v.Value.Value) >= value + 1 then
v.Value.Value = v.Value.Value - 1
end
end
end
end)
-- I hope you can fix the problem in this script and thanks for your help
Use this outside playeradded and use the parameter “player” like this.
thanks but then the player is turning to a so that’s nil too
That function is getting the player that is clicking the “script.Parent”
“player” is a built-in parameter
Sorry if I caused you any misunderstood it return nil, is just a built-in parameter for playerAdded!
nope its turning to a its hard to get the player in this gui
hmm… wait I think I know it now
However, I think you should reorganize the code and separate it into functions.
yes I think that will work. I let you know later
¿This is actually for a gui? charrrrs
yes this will destroy a pet while the player is clicking on a destroy button in the gui
Oh well… if is for a gui you should use remote events from client → server
Check if the player clicked in a client to fire a event to the server and then in the server script you do your stuff.
yes but I need a local script to activate it.
maybe I can fix it with module scripts.
local script → remote events → server
or you can use module scripts since i dont know that much about module scripts
just make sure to add checks to avoid exploiters abusing the client → server connection
Then just do
local player = script:FindFirstAncestorOfClass("Player")
Only if you are determined not to use remote events.
Yes that’s a great idea. I’ll look at it tomorrow