Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Why isn't my click detector working? [no errors]

detect = workspace.Lottery.Man.Head

detect.ClickDetector.MouseClick:Connect(function(plr)
	if math.random(1, 100) == math.random(1, 100) then
		game:GetService("Chat"):Chat(detect, "You have won the lottery! Congratulations", "Red")
	elseif plr.Name == "HappyTimIsHim" then
		game:GetService("Chat"):Chat(detect, "You have won the lottery! Congratulations", "Red")
	else
		game:GetService("Chat"):Chat(detect, "You have lost the lottery. Better luck next time!", "Red")
		
	end
end)

I have made a lottery script for a man. But when I click the head it doesn't do anything. Also if nothing works let me tell u something. I made a hitbox called head and made the normal head named "fakehead" cuz i was too lazy to changed anything.

First script is in StarterGui. Second script is in the clickdetector. The Remote Event is in Replicated storage.

5 comments

0

MouseClick should only be used on the server. this will help, because in turn, you wont need a remote event

0

:/ i have one

0

Wait what do you mean gioni1, he has a RemoteEvent on the Server?

0

i changed it :/

0

cuz of gioni

1 answer

✓ Accepted answer
detect = workspace.Lottery.Man.Head

detect.ClickDetector.MouseClick:Connect(function(plr)
    if math.random(1, 100) == math.random(1, 100) then
        game:GetService("Chat"):Chat(detect, "You have won the lottery! Congratulations", "Red")
    elseif plr.Name == "HappyTimIsHim" then
        game:GetService("Chat"):Chat(detect, "You have won the lottery! Congratulations", "Red")
    else
        game:GetService("Chat"):Chat(detect, "You have lost the lottery. Better luck next time!", "Red")

    end
end)

6 comments

0

oh

0

pretty good script

0

i bet u didn't copy and paste

0

totally didnt

0

Explain.

0

we solved this in chat

This discussion is preserved as it was. New answers, comments, and votes are closed.