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

My script is working in studio but why in the servers it doesn't?

So I have a Local script in StarterPack and it functions 100% in studio but not in servers why is this? Here is my code below.

UIS = game:GetService("UserInputService")
	fire = script:WaitForChild("fire")
	flame1 = game:GetService("ServerStorage"):WaitForChild("Flame")
	plr = script.Parent.Parent
	m = plr:GetMouse()
	UIS.InputBegan:connect(function(Input, gameProc)
		if Input.KeyCode == Enum.KeyCode.Z and not gameProc then
			if plr.Character.RightHand:FindFirstChild("Flame") then
				print("Already Equipped")
			else
				fh = plr.Character.Humanoid:LoadAnimation(fire)
				fh.Priority = 2
				fh:Play()
				weld = Instance.new("Weld")
				flame = flame1:Clone()
				flame.Parent = plr.Character.RightHand
				weld.Parent = plr.Character.RightHand
				weld.Part0 = flame
				weld.Part1 = plr.Character.RightHand
				weld.C0 = CFrame.new(0,0.7,0)
			m.Button1Down:connect(function()
				print("clicked")
				weld:Destroy()
				fh:Stop()
				bv = Instance.new("BodyVelocity")
				bv.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
				bv.Velocity = m.Hit.lookVector*100
				bv.Parent = flame
				flame.Dmg.Disabled = false
				plr.Character.HumanoidRootPart.CFrame = CFrame.new(plr.Character.HumanoidRootPart.Position, Vector3.new(m.Hit.p.X, plr.Character.HumanoidRootPart.Position.Y, m.Hit.p.Z))
				flame.Touched:connect(function(hit)
				if hit.Name ~= "Handle" then
					if hit ~= plr.Character.RightHand then
						print(hit)
					exp = game.ServerStorage.Explode:Clone()
					exp.CFrame = flame.CFrame
					exp.Parent = workspace
					flame:Destroy()
					wait(1)
					exp:Destroy()
						if hit.Parent:FindFirstChild("Humanoid") then
							fp = game.ServerStorage.FireParticle:Clone()
							fp.Parent = hit.Parent.LowerTorso
							fp.Enabled = true
							for i = 1,5,1 do
								wait(1)
								hit.Parent.Humanoid.Health = hit.Parent.Humanoid.Health - 2.5
							end
							fp.Enabled = false
							fp:Destroy()
						end
					end
					end
				end)
				game:GetService("Debris"):AddItem(flame, 7)
				game:GetService("Debris"):AddItem(exp,3)
			end)
			end
		end
	end)

2 comments

0

Is your game Filtering Enabled?

0

No, but it will be soon and then i will add remote events i just want this to work first

2 answers

To use userinputservice it must be in a local script inside a player (StarterPack,StarterGui,StarterPlayerScripts,StarterCharacterScripts). Anything in a player.

7 comments

0

Ok I did this, it at least functions when i press z because it says "fire" is not a child of LocalScript

0

Yet I have the fire animation named exactly "fire" inside of the script I even checked in explorer when it was running and it was there.. again not working in server only studio.

0

Do "fire = script:WaitForChild("fire")" so it waits until "fire" gets loaded into the script.

0

When in game press "f9" to check your console and see what's the problem

0

I am testing in studio going to server testing, and I put a waitforchild on the stuff that didnt load but when i press Z nothing happens no errors in output and nothing being done in real world..

0

roblox world*

0

Are you sure no variable is making the script not work? Such as GameProc? If yes, update the variables inside the script.

this is because you made multiple errors,but i will only tell you a few.For starters when you put a service or a storage it isnt

flame1 = game.ServerStorage.Flame

its supposed to be

flame1 = game:GetService("ServerStorage").Flame

the reason for this is because some things cant be defined as (game.) and need to be used as

game:GetService(" ")

i hoped i helped..well i know this isnt the only error but a massive mistake.I am currently figuring out what else is wrong

4 comments

0

I didn't change anything but thanks though I appreciate if you keep looking

0

That is simply wrong. game.Workspace is a valid statement to grab the workspace. Also, you'd use getService() only when you're GETTING A SERVICE.

1

game.ServerStorage is fine to use; GetService can be used to get a service, yes, but it can also be used to get service's that aren't already present, like the Run Service. Otherwise, it's fine either way.

0

yes i already know about this I just didn't think it made a difference after all it didnt??

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