How would I make this changing collision detection work?

  1. What do you want to achieve? I am trying to get the player to collide with the part, have the part switch to another (pre-planed) part, and repeat until all parts have been touched.

  2. What is the issue? No errors in output, all of the debug print statements are fine, but the player never checks if it collided with the secondary part. I don’t know if I have to setup a separate detection for each of these, (I don’t want to do that because it would just be less complicated if I had it all in one).

  3. What solutions have you tried so far?
    I have tried making a clone of a script and sending data through remote events, but it was very slow & hard to maintain. I switched to having it in the main client script, but the code will not detect any part after the first part.

  4. Screenshots
    my location storage: (yes I know its unoptimized/messy)
    (all of them are object values)

(this code is my entire script. Just to make sure nothing else is messing it up)

local plr = game:FindService("Players").LocalPlayer



local age = plr.leaderstats.Age
local sub = plr.SubStat
local part = 1

local debounce = false

local currentTask = game:FindService("ReplicatedStorage").Tasks:FindFirstChild("Age" .. age.Value):FindFirstChild(sub.Value)
local currentLocation = currentTask.Locations:FindFirstChild("Part" .. part)
local currentText = currentTask.TXT

local text = plr.PlayerGui.Tutorial.CanvasGroup.TextLabel

repeat task.wait() print("Waiting") until currentLocation.POS.Value ~= nil

print("Wait ended")

local destination = game:FindFirstChild(tostring(currentLocation.POS.Value), true)

function refresh()
	currentTask = game:FindService("ReplicatedStorage").Tasks:FindFirstChild("Age" .. age.Value):FindFirstChild(sub.Value)
	currentLocation = currentTask.Locations:FindFirstChild("Part" .. part)
	currentText = currentTask.TXT
	debounce = false
	destination =  game:FindFirstChild(tostring(currentLocation.POS.Value), true)

	for i = 1, #currentText.Value do
		text.Text = string.sub(currentText.Value, 1, i)

	if debounce == false then
		if currentLocation.Parent:FindFirstChild("Part" .. tostring(tonumber(part) + 1)) then	
			--last = part
			part = part + 1
			part = 1
		debounce = true
		print("Touched, " .. part)

I will send any info needed to fix these!

sorry if any of this seems confusing, this is my first devforum post. I am open to any improvements I can do!

So is this printing when needed?

yes it does print for the first part, but not for the second part

Can you send a video of what is happening at the moment?

how would i upload a video? file is too large.

You must be rendering it in 4k resolution then. The file size for uploading videos on devforums is more than enough for even a 5 minute video. try knocking your resolution down to 720p 16:9 ratio.

Or if I am completely wrong about that, try appending it to your original post above. That may just do the trick.

tried doing that

this happens every time

How long is your video? What software are you recording with? 10MB is quite a hard limit to reach for the display that you are doing.

40 ish seconds, recording with obs studio, 30 fps.

try to do it in 15 seconds. That possible?

For context:
the part 1 is the door, part 2 is the living room carpet, part 3 is the chair

I see the issue. The problem you are running into right now is just a jumbled mess of “this, then next, then later” arrangements. Simplify your life a ton by just checking if the HumanoidRootPart of the character hits any of these parts. Then proceed to the next task.

Since you are using Object Values, you can create a BoolValue that checks off a location if it has alredy been progressed through. The method you are performing right now is extremely unreliable. Furthermore, if it is multiplayer, the script will confuse itself even more.


How would the server get confused? Its a localscript

1 Like

Wrong phrasing. You are checking if the part is touched. What if another player touches it? The local script will still acknowledge that touch and take it in as legitimate. Make it come from the Local Player’s character itself.

I didn’t even think of that,
Thank you

1 Like

Script on, brother. Glad I was able to help.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.