Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How come the fire appears in Studio, but not online in Play Mode?

I tried everything, the fire won't work online.

Tool = script.Parent
fire = script.Parent.Chamber.Fire
mousedown = false
-- Variables

function makefire()
	local area = Instance.new("Part")
	area.CanCollide = false
	area.Size = Vector3.new(10, 10, 10)
	area.CFrame = CFrame.new(script.Parent.SpawnPos.CFrame.p)
	area.Transparency = 1
	area.Parent = workspace
	local cf = script.filter:Clone()
	cf.Parent = area
	cf.Disabled = false
	local dmg = script.damage:Clone()
	dmg.Parent = area
	dmg.Disabled = false
end

mouseDown = function(mouse)
	if not mousedown then
		mousedown = true
		while mousedown do
			makefire()
			fire.Enabled = true
			wait(1)
		end
	end
	mousedown = false
end

mouseup = function(mouse)
	mousedown = false
	fire.Enabled = false
end


Tool.Equipped:connect(function(mouse)
	
	local Humanoid = script.Parent.Parent.Humanoid
	mouse.Icon="rbxasset://textures\\GunCursor.png"
	animation = Instance.new("Animation")
	animation.AnimationId = "http://www.roblox.com/Asset?ID=331030667"
	animTrack = Humanoid:LoadAnimation(animation)
	animTrack:Play()
	
	mouse.Button1Down:connect(function() mouseDown(mouse) end)
	mouse.Button1Up:connect(function() mouseup(mouse) end)

	grip = Instance.new("Weld",script.Parent.Parent.Torso)
	grip.Part0 = script.Parent.Parent.Torso
	grip.Part1 = script.Parent.Handle
	grip.C0 = CFrame.new(0,0,-2)*CFrame.Angles(math.rad(20),math.rad(20),0)
	grip.Name = "Grip"
if script.Parent.Parent:FindFirstChild("Right Arm")then
	for _,v in pairs(script.Parent.Parent["Right Arm"]:GetChildren())do
		if v:IsA("Weld") then
			game.Debris:AddItem(v,0)
		end
	end
    end
end)
Tool.Unequipped:connect(function()
--  game.Debris:AddItem(weld2,0)
	animTrack:Stop()
	game.Debris:AddItem(animation,0)
    game.Debris:AddItem(grip,0)
	fire.Enabled = false
end)

This is a ServerScript.

1 answer

✓ Accepted answer
--I suggest you put this entire piece of code in a Client Sided Script. Aka local then it should work fine as usual.
Tool = script.Parent
fire = script.Parent.Chamber.Fire
mousedown = false
-- Variables

function makefire()
    local area = Instance.new("Part")
    area.CanCollide = false
    area.Size = Vector3.new(10, 10, 10)
    area.CFrame = CFrame.new(script.Parent.SpawnPos.CFrame.p)
    area.Transparency = 1
    area.Parent = workspace
    local cf = script.filter:Clone()
    cf.Parent = area
    cf.Disabled = false
    local dmg = script.damage:Clone()
    dmg.Parent = area
    dmg.Disabled = false
end

mouseDown = function(mouse)
    if not mousedown then
        mousedown = true
        while mousedown do
            makefire()
            fire.Enabled = true
            wait(1)
        end
    end
    mousedown = false
end

mouseup = function(mouse)
    mousedown = false
    fire.Enabled = false
end


Tool.Equipped:connect(function(mouse)

    local Humanoid = script.Parent.Parent.Humanoid
    mouse.Icon="rbxasset://textures\\GunCursor.png"
    animation = Instance.new("Animation")
    animation.AnimationId = "http://www.roblox.com/Asset?ID=331030667"
    animTrack = Humanoid:LoadAnimation(animation)
    animTrack:Play()

    mouse.Button1Down:connect(function() mouseDown(mouse) end)
    mouse.Button1Up:connect(function() mouseup(mouse) end)

    grip = Instance.new("Weld",script.Parent.Parent.Torso)
    grip.Part0 = script.Parent.Parent.Torso
    grip.Part1 = script.Parent.Handle
    grip.C0 = CFrame.new(0,0,-2)*CFrame.Angles(math.rad(20),math.rad(20),0)
    grip.Name = "Grip"
if script.Parent.Parent:FindFirstChild("Right Arm")then
    for _,v in pairs(script.Parent.Parent["Right Arm"]:GetChildren())do
        if v:IsA("Weld") then
            game.Debris:AddItem(v,0)
        end
    end
    end
end)
Tool.Unequipped:connect(function()
--  game.Debris:AddItem(weld2,0)
    animTrack:Stop()
    game.Debris:AddItem(animation,0)
    game.Debris:AddItem(grip,0)
    fire.Enabled = false
end)

Please upvote and accept my answer if it helped it's much appreciated.

2 comments

0

OMG How DID YOU FIGURE THAT OUT? PLEASE RESPOND!

0

The client is the software that you and other players run on the computer in order to play the game. Client-side LocalScripts run on every player's computer. Therefore, this script would work without failure in online mode. And this goes for any other script similar to this.

This discussion is preserved as it was. New answers, comments, and votes are closed.