I’m trying to make a script that detects if A Value In the player is = 1 then destroys a part
local clickDetector = game.Workspace.Spawn.ClickerPart.ClickDetector
local Stick = game.Workspace.Spawn["Meshes/stick"]
clickDetector.MouseClick:Connect(function()
game.Workspace.Spawn["Meshes/stick"].Transparency = 0
game.Workspace.Spawn.Wood.Transparency = 0
end)
if game.Players.LocalPlayer.ValueHammer.Value == 1 then
Stick:Destroy()
end
Here is the script that makes the value
game.Players.PlayerAdded:Connect(function(player)
local VelueHammer = Instance.new("IntValue", player)
VelueHammer.Name = "ValueHammer"
But when i load up the game, This error message appears.
function init(player)
local VelueHammer = Instance.new("IntValue", player)
VelueHammer.Name = "ValueHammer"
end
for i, player in next, game.Players:GetPlayers() do
init(player) -- incase PlayerAdded didnt catch the previous players
end
game.Players.PlayerAdded:Connect(init)