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

How can I make a working click part that enables a script?

function onClicked()
game.Players.LocalPlayer.Backpack.StandSummon.Disabled = false
	
end 

script.Parent.ClickDetector.MouseButton1Click:connect(onClicked)

This doesnt work, Im trying to make a part so when you click it, it makes a script that was in starterpack but moves to backpack when join game become enabled. But it doesnt work. Can someone help me?

2 comments

0

See my edited version of script

0

I have answered, please have a look below at answers.

2 answers

✓ Accepted answer

I've seen that you were using MouseButton1Click, that is totally wrong. It's used from TextButtons in ScreenGuis. The correct term is MouseClick. Also, I'm saying that you can't use LocalPlayer via Scripts, and it is used in LocalScripts, NOT Scripts. Now you can replace your code to this:

game.Players.PlayerAdded:Connect(function(player)
    local function onClicked()
        player.Backpack:WaitForChild("StandSummon").Disabled = false
    end
    script.Parent.ClickDetector.MouseClick:Connect(onClicked)
end)

This will surely work, I promise.

Make sure you are setting the MaxActivationDistance of the clickdetector to something high. And it is most likely not a MouseButton1click property that activates the clickdetector, but it can work as:

script.Parent.ClickDetector.Activated:Connect(onClicked) --Did not work


script.Parent.ClickDetector.MouseClick:connect(onMouseClick) --Must work

2 comments

0

does not work, thanks for trying to help though

0

then try clickDetector.MouseClick:connect(onMouseClick)

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