Now before I go ahead and answer this:
- Where is the "script.Parent.ClickDetector" located? (this should be somewhere under Workspace)
- The main concern I'm seeing just by looking at the code is that the ClickDetector Function is inside the PlayerAdded function, making me think that clicking the Detector won't set off the second function.
- You've already called the player inside the PlayerAdded so you don't need the "player =" phrase.
- I tried this out, and found that you can't add a Bool Value to the Backpack unless it was pre-placed inside the "Starter Pack" (the reason for this is the Backpack is meant to carry Tools) so you'll need to add the Bool Value to the Player instead.
With all this in mind, I've adjusted the code like this:
game.Players.PlayerAdded:Connect(function(player)
local QuirkTrue = Instance.new("BoolValue", player)
QuirkTrue.Name = "QuirkTrue"
end)
function onClick(click)
local RS = game:GetService("ReplicatedStorage")
local QuirkTrue = click.QuirkTrue
if QuirkTrue.Value == true then return end
if QuirkTrue.Value ~= true then
local quirk = RS.Quirks.Common
local quirktable = {}
quirktable[1] = quirk.Explosion
quirktable[2] = quirk.Electrification
quirktable[3] = quirk.Engine
quirktable[4] = quirk.Quirkless
quirktable[5] = quirk.Regeneration
for i = 1, 1 do
local localquirk = quirktable[math.random(1,5)]
local localquirk2 = localquirk:Clone()
localquirk2.Parent = click
QuirkTrue.Value = true
end
end
end
script.Parent.ClickDetector.MouseClick:connect(onClick)
The first function is the PlayerAdded Function you used, however, it is shortened to only give the Bool Value.
The second function is the ClickDetector.
Assuming you are using Particles, you would want to replace the following line of code
localquirk2.Parent = click
with this:
local char = game.Workspace:FindFirstChild(click.Name)
local root = char.HumanoidRootPart
localquirk2.Parent = root
this way, the Particle Emitter would be in the Character, rather than the Player (which is called by "click")