Here is my script right now
script.Parent.MouseClick:Connect(function(Player) local Character = Player.Character local Humanoid = Character:FindFirstChild('Humanoid') player = game:GetService("Players").LocalPlayer stats = player:findFirstChild("leaderstats") power = stats:findFirstChild("Power") power.Value = power.Value + 1
if Humanoid then local HS = Humanoid:FindFirstChild('HeadScale') local BDS = Humanoid:FindFirstChild('BodyDepthScale') local BWS = Humanoid:FindFirstChild('BodyWidthScale') local BHS = Humanoid:FindFirstChild('BodyHeightScale') if HS and BDS and BWS and BHS then HS.Value = HS.Value + 0.03 BDS.Value = BDS.Value + 0.015 BWS.Value = BWS.Value + 0.015 BHS.Value = BHS.Value + 0.015 local brick = script.Parent.Parent
for i = 1,2 do brick.CFrame = brick.CFrame*CFrame.new(0,-5,0) wait(15)
brick.CFrame = brick.CFrame*CFrame.new(0,5,0)
end end
end end)
it works in studio, but it never works in-game, can someone please help me.
Your error is this : player = game:GetService("Players").LocalPlayer
first when using the MouseClick event it would give you the Player who clicked the button so you don't have to use LocalPlayer and LocalPlayer doesn't work with server scripts. And you also forgot to add local on some lines.
script.Parent.MouseClick:Connect(function(player) player.leaderstats.Power.Value = player.leaderstats.Power.Value + 1 local character = player.Character local humanoid = character:FindFirstChild('humanoid') if Humanoid ~= nil then local HS = Humanoid:FindFirstChild('HeadScale') local BDS = Humanoid:FindFirstChild('BodyDepthScale') local BWS = Humanoid:FindFirstChild('BodyWidthScale') local BHS = Humanoid:FindFirstChild('BodyHeightScale') if HS and BDS and BWS and BHS ~= nil then HS.Value = HS.Value + 0.03 BDS.Value = BDS.Value + 0.015 BWS.Value = BWS.Value + 0.015 BHS.Value = BHS.Value + 0.015 local brick = script.Parent.Parent for i = 1,2 do brick.CFrame = brick.CFrame*CFrame.new(0,-5,0) wait(15) brick.CFrame = brick.CFrame*CFrame.new(0,5,0) end end end end)
Also i don't recommend putting the script in the click detector but it will work just fine.