Why isnt this working?

return function(World,LocalPlayer)

	World["Red Rose"].ClickDetector.MouseClick:Connect(function()
		game.ReplicatedStorage.Dialogue:FireServer({initiate = true,target = "Rose"})
	end)
		
	for _,I in pairs(LocalPlayer.Backpack:GetChildren()) do
		if I.Name == "Rose" then
			World["Red Rose"].Transparency = 1
			World["Red Rose"].ClickDetector.MaxActivationDistance = 0
		end
	end
	LocalPlayer.Backpack.ChildAdded:Connect(function(ch)
		if ch.Name == "Rose" then
			World["Red Rose"].Transparency = 1
			World["Red Rose"].ClickDetector.MaxActivationDistance = 0
		end
	end)
end

The above code is ran in a module-script which is called by a local script when the world loads. No errors appear whatsoever, I printed at the bottom and it printed. I tried just calling the localplayer inside of it instead of telling it when I initially require the module, but nothing changed. I know that the script is atleast running because I am able to activate the click detector. I hate dead-ends like these

1 Like

Try printing in some sections of your code and determine where it gets stuck and does not continue.

Did you read the post. Like at all
Cause I did that already like I said

adding some print statements to your code to help debug the issue. For example, you could add a print statement inside the if statement that checks if the player has a “Rose” object in their backpack, like this:

for _,I in pairs(LocalPlayer.Backpack:GetChildren()) do
    if I.Name == "Rose" then
        print("Rose found in backpack")
        World["Red Rose"].Transparency = 1
        World["Red Rose"].ClickDetector.MaxActivationDistance = 0
    end
end

This will help you determine if the code is correctly detecting the “Rose” object in the player’s backpack. You could also add print statements to other parts of the code to help narrow down where the issue might be occurring.

1 Like