New to scripting and trying to fix and old tool and i keep get the forget to implement onserverevent? I know im looking past it
local input = script.Parent.Input
local mouse_pos = Vector3.new()
local mouse_hit = nil
local mouse_target = nil
local mouse_pos = nil
local player = nil
input.OnServerEvent:Connect(function(client,action,...)
wait()
if client == script.Parent.Parent.Parent then
if action == 'mouse_pos' then
local out = ...
mouse_pos = out
elseif action == 'mouse_target' then
local out = ...
mouse_target = out
elseif action == 'Player' then
local out = ...
player = out
elseif action == 'mouse_hit' then
local out = ...
mouse_hit = out
elseif action == 'Down1' then
local out = ...
if out == true then
onButton1Down()
end
end
end
end)
function onButton1Down(mouse)
Target = mouse_target
Hit = mouse_hit
if Target:IsDescendantOf(workspace.Bases.RedBase) or Target:IsDescendantOf(workspace.Bases.BlueBase) and Target.Name ~= "BASE" then
c = script.Fire:clone()
c.Parent = Target
c.Disabled = false
end
end
function onSelected(mouse)
mouse.Button1Down:connect(function() onButton1Down(mouse) end)
end
script.Parent.Selected:connect(onSelected)
Actually got it working with testing a few times. Now im just trying to figure out how id add fire and smoke effects to the bricks effected by the burn. If you could possibly help. But i do have the tool functioning exactly how it should.
Exactlyyyyyy. The code atm just changes the color(At times will stay one color not sure) when it spreads and explodes sometimes but doesnt add fire nor smoke which id like but not sure how id approach adding it to said script. Ill post it below.
local Model = script.Parent.Parent
Colors = {"Really black","Black","Bright red","Dark orange"}
Brightness = script.Parent.BrickColor.r + script.Parent.BrickColor.g + script.Parent.BrickColor.b
Brightness = Brightness
Brightness = math.floor(Brightness+.8)
script.Parent.BrickColor = BrickColor.new(Colors[Brightness])
script.Parent.Transparency = math.random(2,4)*.1
Model.Parent.FireCount.Value = Model.Parent.FireCount.Value + 1
script.Parent:BreakJoints()
a = 1
Burn = true
while Burn do
wait(math.random(2,3))
if a >= 4 then
if math.random(1,8) == 8 then
Explosion = Instance.new("Explosion")
Explosion.Parent = script.Parent
Explosion.Position = script.Parent.Position
end
Burn = false
end
if Model.Parent.FireCount.Value > 55 then
Burn = false
end
a = a + 1
getModel = Model:getChildren()
Distance = 10
Block = nil
if Burn then
for i=1, #getModel do
if (getModel[i].Position-script.Parent.Position).magnitude < Distance and getModel[i].Name ~= "BASE" and getModel[i] ~= script.Parent and getModel[i]:findFirstChild("Fire") == nil then
Distance = (getModel[i].Position-script.Parent.Position).magnitude
Block = getModel[i]
if Distance < 5 then
break
end
end
end
if Block ~= nil then
Clone = script:clone()
Clone.Parent = Block
end
end
end
Have no idea how but i somehow figured it out thankfully. it spreads, explodes, burns and smokes. Would like it to remove the particles(smoke and fire) after like 10 seconds so it doesnt lag people but it works so not too worried about it