I have a sign that upon Equipping shows all gamepasses by the user, kinda like in pls donate. Creation is handled by server, and i am wondering what is the optimal way to handle activations of those buttons? Make a localscript to parse through every tool equipped by any player and check if its a sign and has speciefic buttons?
One option would be to utilize CollectionService
, basically, when ever a Tool (your sign) is added into the game (i.e., in someone’s inventory), you will assign it a tag.
In some LocalScript
on the client, you will listen for these tags using the signal GetInstanceAddedSignal
, when your specific tag is added to a sign and the signal picks it up, you will parse through the sign’s UI to find the buttons and connect them to the appropriate input signals (like MouseButton1Click
or Activated
, etc).
Thank you for info about CollectionService, but now im facing another problem:
For some reason theese buttons created by server are visible to local scripts, but they are not firing activated Event, heres the local script:
function handle(sf)
wait(0.5)
for i,v : TextButton in pairs(sf:GetChildren()) do
if v:IsA('TextButton') then
print('Found Button')
v.Activated:Connect(function()
print('Activated')
-- game.MarketplaceService:PromptGamePassPurchase(game.Players.LocalPlayerm,v.idofgamepass.Value)
end)
end
end
end
cs:GetInstanceAddedSignal('donationui'):Connect(function(surfacegui)
print('Detected')
handle(surfacegui.ScrollingFrame)
end)
It prints, but doesnt react on clicking, could it be because its a tool parented to LocalPlr.Character?
Detected
Found Button 3x
Dont really know how different Activated is to MouseButton1Click
I just use the latter; it supports all other platforms eitherway
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.