#Is anyone using CollectionService?
89 messages · Page 1 of 1 (latest)
@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
sensd cscirpt
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
press f8 and then run the command print(game:GetService("CollectionService"):GetTagged("CheckPoint")
)
and screenshot the table
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
weird
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
no I think you helped me alot
this should fix it
YES
IT WORKS
ITS BC OF RENDERING
tysm
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
yea but its not that big of an issue to warp it around
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
ye
yo @hoary plank could you help me again
h
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
send the table or variable for checkPoints
Touched is not a valid member of Texture "Workspace.checkPoints.SpawnLocation.Texture"
k
looks like this
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
me2
this fixes it but i still dont get it why im in the texture
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
k goodnight
