CanCollide not turning false

I’m trying to figure out how to make this part CanCollide set to false after rejoining when having a boolvalue set to true, but It doesn’t work and I don’t know the issue with the code, It’s a local script in StarterPlayerScript.

Here’s the code:

local worldblock = game.Workspace:WaitForChild("World1block")

game.Players.PlayerAdded:Connect(function(player)
	if player.Worlds.World2.Value == true then 
		worldblock.CanCollide = false
	end
end)

Are you sure that this condition is being met
image

1 Like

Try add a print statement after the if statement. The boolean may not be true.

if player.Worlds.World2.Value == true then 
   print("true")
end
1 Like

Maybe it’s like what @astraIboy says?
You can use a print statement to see if the condition works or if there is something wrong with that!

1 Like

(Assuming you have another script that turns the world2 value to true)

If the default value of World2 is false when you join the game, then you might be checking the condition before the value could have time to change to true.

If that’s not the case, then refer to the answers above.

1 Like

Hello, Just started working on this again.

I got it to work after changing the script, but it wouldnt print anything in a studio game which left me confused on why it didnt even print anything when the player had join, only in a local server inside the studio, not sure why?

local worldblock = game.Workspace:WaitForChild("World1block")
local prompt = workspace:WaitForChild("BuyPromptWorld1").ProximityPrompt

game.Players.PlayerAdded:Connect(function(player)
	print("joined")
	wait(2)
	if game.Players.LocalPlayer.Worlds.World2.Value == true then
		print("wadwasdwa")
		worldblock.CanCollide = false
		prompt:Destroy()
	end
end)

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