ClickDetector is being really lazy today

Back again! Continuing on my game, a ClickDetector i set up doesnt want to work. Server code is WIP but im testing out if the ClickDetectors and prox. prompts still arent working. Image taken from studio

--LocalScript
script.Parent.ClickDetector.MouseClick:Connect(function(player)
	game.ReplicatedStorage.UpgradeBought:FireServer(game.Players.LocalPlayer, script.Parent.Name)
	print("x2 upgrade bought by "..player.Name)
end)

You have to make everything in a server script.

--ServerScript
script.Parent.ClickDetector.MouseClick:Connect(function(playerThatClicked)
	game.ReplicatedStorage.UpgradeBought:FireServer(playerThatClicked, script.Parent.Name)
	print("x2 upgrade bought by "..playerThatClicked.Name)
end)

LocalScripts do not run when they are a descendant of the workspace unless they’re in the character so you must move the script somewhere else such as the PlayerGui or replace the LocalScript with a regular script and change the RunContext to client

That is the solution, except it has to be a BindableEvent and it needs to be :Fire()
I feel dumb sometimes lol

1 Like

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