I have an object that appears to a player, only when they click on another object in my game. To accomplish this, the 'hidden' object is parented from replicated storage to the workspace via a remote onclient event. However, I'd like the player to be able to click on and interact with this object when it appears, but I can't get anything to happen. There's a click detector and script in the object that simply says:

script.Parent.ClickDetector.MouseClick:Connect(function()
	print ("Hello World")
end)

No error message displays, nor does the printed message when I click it. I've tried making this as a local script and as a regular script. How do I make the object do anything, even as simple as print?

EDIT: More info - So this all takes place in a library and your job is to return the library books to the correct spots. Here is the script that is in the pile of books that need to be returned:

script.Parent.ClickDetector.MouseClick:Connect(function(player)
	print("clicked!")
if player.PlayerGui:FindFirstChild("BookReturnGame") == nil and player.Jobs.CurrentJob.Value == "Book Sorter" then
	script.Parent.Parent.BookReturnGame:clone().Parent = player.PlayerGui
	player.PlayerGui.BookReturnGame.Cover.Visible = true
	local myTable = { 'N1' }
	local Chosen = ( myTable[ math.random( 1, #myTable) ] )
	print (Chosen)
	player.PlayerGui.BookReturnGame.Cover.Title.Text = script.Parent.Parent.Books:FindFirstChild(Chosen).Title.Value
	player.PlayerGui.BookReturnGame.Cover.Summary.Text = script.Parent.Parent.Books:FindFirstChild(Chosen).Summary.Value
	player.PlayerGui.BookReturnGame.Genre.Value = script.Parent.Parent.Books:FindFirstChild(Chosen).Genre.Value
	game.ReplicatedStorage.BookSorterSpots:FireClient(player)
	print("fire the event")

elseif player.PlayerGui.BookReturnGame ~= nil and player.Jobs.CurrentJob.Value == "Book Sorter" then
	player.PlayerGui.BookReturnGame.Cover.Visible = true
	local myTable = { 'N1' }
	local Chosen = ( myTable[ math.random( 1, #myTable) ] )
	print (Chosen)
	player.PlayerGui.BookReturnGame.Cover.Title.Text = script.Parent.Parent.Books:FindFirstChild(Chosen).Title.Value
	player.PlayerGui.BookReturnGame.Cover.Summary.Text = script.Parent.Parent.Books:FindFirstChild(Chosen).Summary.Value
	player.PlayerGui.BookReturnGame.Genre.Value = script.Parent.Parent.Books:FindFirstChild(Chosen).Genre.Value
	game.ReplicatedStorage.BookSorterSpots:FireClient(player)
	print("fire the event")

	end
end)

The remote event that is found in ReplicatedStorage with the local script in ReplicatedFirst makes bricks show up that I want the player to click on to return the book. Here is the local script for the remote event:

game.ReplicatedStorage:WaitForChild("BookSorterSpots")
game.ReplicatedStorage.BookSorterSpots.OnClientEvent:Connect(function(player)
	if game.Workspace:FindFirstChild("BookReturnSpots") then
		print("remote event request received! Visible, turning invisible")	
		player = game.Players.LocalPlayer
		game.Workspace:FindFirstChild("BookReturnSpots").Parent = game.ReplicatedStorage
	else 
		print("remote event request received! Invisible, turning visible")	
		player = game.Players.LocalPlayer
		game.ReplicatedStorage.BookReturnSpots.Parent = game.Workspace
	end
end)

The spots that are summoned have click detectors and the code in my original question but do not print. I hope this helps explain the issue!

2 comments

0

Not enough information for me to see what's happening, consider adding a screen shot of the whole thing.

0

Okay thanks, I'm not really sure what I can screen shot, but I'll add more script.