i have a leader stat in the server script strage which creates the values, heres the server script
local PlayerS = game:GetService("Players")
PlayerS.PlayerAdded:Connect(function(player)
local Resources = Instance.new("Folder",player)
Resources.Name = "Resources"
local Wood = Instance.new("NumberValue",Resources)
Wood.Value = 10
Wood.Name = "Wood"
local Rock = Instance.new("NumberValue",Resources)
Rock.Value = 5
Rock.Name = "Rock"
local Metal = Instance.new("NumberValue",Resources)
Metal.Value = 10
Metal.Name = "Metal"
end)
and here is the changing event
local RS = game:GetService('ReplicatedStorage')
local Event = RS:WaitForChild('Metal')
-- PlaceBlock Event
Event.OnServerEvent:Connect(function(plr)
plr.Resources.Metal.Value = plr.Resources.Metal.Value - 1
end)
and here is the event sender
script.Parent.Activated:Connect(function()
if value ~= 1 then
local target = mouse.Target
if target then
local surface = mouse.TargetSurface
local pos = Surface(surface)
Event:FireServer(target,pos,Block_Choice)
value = value - 1
end
if value == 1 then
if target then
local surface = mouse.TargetSurface
local pos = Surface(surface)
Event:FireServer(target,pos,Block_Choice)
Me:FireServer()
equipped = false
part.Transparency = 1
part.Position = Vector3.new(1,1,1)
script.Parent:Destroy()
end
end
end