Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

[2 questions inside... am i allowed to do that?]

Asked by 4 years ago

Question 1:

How would I get a random asset ID from the catalog?

so I have a random advertising script (don't ask why i did that) and I wanted to get a random asset from the catalog that isn't a gamepass/devproduct. how would I put it into something like a table?

for example, i'd want to get only 30 items from the catalog, then choose one of them

heres the current script i have

local ids={} -- but how would i fill this up?
local chosenid = math.random(1,#ids) 
local id = ids[chosenid]

if not Marketplace:UserOwnsGamePassAsync(player.UserId,7218055) or not player.UserId==1045694334 or not player.UserId==29320767 or not player.UserId==178485823 then
        Marketplace:PromptGamePassPurchase(player,id)
    end

but how would i fill the table?

-

-

-

Question 2

bullets not facing the target?

whenever i call in the airstrike i made it never points to the mouses Target

server

local Event = game.ReplicatedStorage.Event1

local function airstrike(player,MouseHit)

local assets = game.Lighting.Assets
local folder = Instance.new("Folder")
folder.Parent = workspace
folder.Name = "AirstrikeCache"

print(MouseHit) --checker

                wait(6)
                    for i = 1,100 do
                        local grenade=assets.AirstrikeBullet:Clone()
                        grenade.CFrame = CFrame.new(grenade.Position, MouseHit.Position)
                        grenade.creator.Value = player
                        grenade.Parent=folder
                        grenade.bulletscript.Disabled=false
                    local gs=script.gunshot:Clone()
                    gs.PlaybackSpeed = math.random(0,1).."."..math.random(5,9)
                    gs.Parent=grenade
                    gs:Play()
                    wait(.0025)
                    end
            wait(3)
            folder:Destroy()
end

Event.OnServerEvent:Connect(airstrike)

tool (client)

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local RemoteEvent = ReplicatedStorage:WaitForChild("Event1")
local UserInputService = game:GetService("UserInputService")

local Players = game:GetService("Players")
local LocalPlayer = Players.LocalPlayer -- from a LocalScript
local mouse = LocalPlayer:GetMouse()

local AirstrikeController = workspace.ScriptFile.MainGameScripts.AirstrikeController
local Tool = script.Parent

enabled = false


local function onInputBegan(input, gameProcessed)
        if input.UserInputType == Enum.UserInputType.MouseButton1 and enabled==true then
            local mousepos=mouse.Target
        RemoteEvent:FireServer(mousepos)
        wait()
        Tool.Laser.enabled.Value=false wait() Tool.Parent=workspace
                end
        end

function onEquip()
    enabled=true
    Tool.Laser.enabled.Value=true
end

function onUnequip()
    enabled=false
    Tool.Laser.enabled.Value=false
end

UserInputService.InputBegan:Connect(onInputBegan)
Tool.Equipped:Connect(onEquip)
Tool.Unequipped:Connect(onUnequip)
3
For question 1, using MarketPlaceService, I don't think you'd be able to get all the catalog ID's without manually inserting them into the table. killerbrenden 1537 — 4y
0
@killerbrenden thanks for letting me know, i only need about 20-30 items anyways. speedyfox66 237 — 4y

Answer this question