#Is anyone using CollectionService?

89 messages · Page 1 of 1 (latest)

frigid delta
#

Just ping me please, I need LIVE support with CollectionService.
Im a faster learner and I js need 1 question explained, ima not waste much of your time.

hoary plank
#

@frigid delta

frigid delta
#

yo

#

Okay so look I have an like tp system in my game and I am getting all checkPoints with collection service, then my CheckPoints have attributes applied, 1,2,3,4.... etc

#

so my issue is that wehn I getting all checkpoints sometimes it does not get the checkpoints from 1-12 or 1-8

#

how can I prevent that

#

my script even has a task.wait(1) implemented at the start so everything can load in

hoary plank
#

sensd cscirpt

frigid delta
#
task.wait(1)
local ScreenGui = script.Parent
local forward = ScreenGui.forward
local back = ScreenGui.back
local stageText = ScreenGui.TextLabel
local resetButton = ScreenGui.reset
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local stage = player.leaderstats.Stage
local checkPoints = game:GetService("CollectionService"):GetTagged("CheckPoint")
local UserInputService = game:GetService("UserInputService")
local tpStage = stage.Value

local function setStageText()
    stageText.Text = tostring(tpStage)
end
setStageText()

local function teleportToStage(targetStage)
    for _, checkPoint in pairs(checkPoints) do
        print(checkPoint:GetAttribute("Stage"))
        if checkPoint:GetAttribute("Stage") == targetStage then
            character:MoveTo(checkPoint.Position)
            return
        end
    end
end

local function stageForward()
    if tpStage < stage.Value then
        tpStage = tpStage + 1
        teleportToStage(tpStage)
        setStageText()
        print(tpStage)    
    end
end
forward.MouseButton1Click:Connect(stageForward)

local function stageBack()
    if tpStage > 0 then
        tpStage = tpStage - 1
        teleportToStage(tpStage)
        setStageText()
        print(tpStage)
    end
end
back.MouseButton1Click:Connect(stageBack)
#

you dont need to worry about the not used variables

#

there are other things in the script but it would be too long to send

#

no errors

#

I fr do not get it, cause it already worked 100% fine, but then it just keeps stopping at like 35-25 or 1-8 or 1-12

hoary plank
#

press f8 and then run the command print(game:GetService("CollectionService"):GetTagged("CheckPoint")
)

#

and screenshot the table

frigid delta
#

16:29:57.702 ▼ {
[1] = SpawnLocation,
[2] = SpawnLocation,
[3] = SpawnLocation,
[4] = SpawnLocation,
[5] = SpawnLocation,
[6] = SpawnLocation,
[7] = SpawnLocation,
[8] = SpawnLocation,
[9] = SpawnLocation,
[10] = SpawnLocation,
[11] = SpawnLocation,
[12] = SpawnLocation,
[13] = SpawnLocation,
[14] = SpawnLocation,
[15] = SpawnLocation,
[16] = SpawnLocation,
[17] = SpawnLocation,
[18] = SpawnLocation,
[19] = SpawnLocation,
[20] = SpawnLocation,
[21] = SpawnLocation,
[22] = SpawnLocation
} - Client

#

cant screenshot too long

#

and like u can see its not until 35

#

BUT WHY

hoary plank
#

weird

frigid delta
#

I mean im doing this right, right?

hoary plank
#

this is something to do with roblox rendering i think
i dont know how roblox studio does it's things

#

it's a far cry but maybe try waiting longer

frigid delta
#

ok if it has todo with rendering i may know why 😭

hoary plank
#

What the skibidi

#

Gyat

frigid delta
#

its kinda long

hoary plank
#

yeah

#

wait till someone else comes around

#

sorry

frigid delta
#

this should fix it

#

YES

#

IT WORKS

#

ITS BC OF RENDERING

#

tysm

hoary plank
#

yw

#

yay

#

but you know there should be a workaround aswell

#

i dont think you have to make it wrap around

#

it's just im not good neough yet to know that solution

frigid delta
#

yea but its not that big of an issue to warp it around

hoary plank
#

guess not

#

but in the future yk some other rthigs might happen u should look up how roblox rendering works or whatever

#

anyways
awesome sauce

frigid delta
#

yo @hoary plank could you help me again

hoary plank
#

h

frigid delta
#
for i, checkPoint in pairs(checkPoints) do
    checkPoint.Touched:Connect(function(hit)
        onTouch(hit, checkPoint)
    end)
end

im getting the error that Touched is not a valid member of Texture, but Im not even in that texture why isnt it taking the checkPoint here, has it todo that the texture is ontop of the checkPoint and im touching the checkpoint

hoary plank
#

send the table or variable for checkPoints

frigid delta
#
Touched is not a valid member of Texture "Workspace.checkPoints.SpawnLocation.Texture"
#

k

#

looks like this

hoary plank
#

oh wait dude

#

i just looked at the script above

#

uh

#

wait a sec

#

hold on

#
for i, checkPoint in pairs(checkPoints) do
    print(checkPoint.Name)
    checkPoint.Touched:Connect(function(hit)
        onTouch(hit, checkPoint)
    end)
end
#

try this

#

print statements are my love
i love debugging with print statements

frigid delta
frigid delta
#

this fixes it but i still dont get it why im in the texture

hoary plank
#

me neither

#

im new to this whole thing aswell

#

bbut uh

#

yeah i dont know

#

i tried looking at my own scripts that used collection service

#
--TODO: Use attributes to determine whether the button with the attribute is disabled or not

local CollectionService = game:GetService("CollectionService")

for _, button in CollectionService:GetTagged("Button") do

    local humanoidTouched
    local touchedEvent = Instance.new("BindableEvent")
    touchedEvent.Parent = button
    touchedEvent.Name = "Touched"

    while true do
        task.wait(0.1)

        local function getHumState()
            for _, hit in workspace:GetPartsInPart(button) do
                humanoidTouched = false
                if not hit.Parent:FindFirstChild("Humanoid") then continue end

                humanoidTouched = true
                return humanoidTouched
            end
            return humanoidTouched
        end
        local humState = getHumState()
        touchedEvent:Fire(humState)
    end
end
#

this works just fine

#

idk

frigid delta
#

its weird idk

#

im also getting Texture here but I dont know why

#

oh god

hoary plank
#

nvm

#

i read that wrong

#

wait

frigid delta
#

I think your right tho

#

cause in the code samples they also add a :isA("BasePart")

hoary plank
#

it's like

#

10 something

#

pm

#

where im at

#

im a slepey

frigid delta
#

k goodnight