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

Help! My script did not work after putting a function! [?]

So yes, I was putting both RemoteEvent function and void, and I am new to it. And after that. I tested it both server and client, but when I used the GUI Button it did not work. Any problems why? (I did not received errors)

+, I am trying to make magic spells and it worked before I added the function and the void. But I don't want an invisible combat and not damage other players or NPC.

LONG LINE OF SCRIPTS AHEAD! So Imma skip it to the error part to prevent scripts from getting copied.


	mouse.Button1Down:Connect(function()
		remote.OnClientEvent:Connect(function()

					if cooldown == true and activate == true then
						
		if mana.Value >= 100 then
			mana.Value = mana.Value - 100
		cooldown = false
		
		local animation = Instance.new("Animation")
		animation.AnimationId = animationid
		animation.Parent = character
		
		
		character:FindFirstChild("Humanoid").WalkSpeed = 0
		character:FindFirstChild("Humanoid").JumpPower = 0

		character:FindFirstChild("HumanoidRootPart").Anchored = true
		local goal1 = {}
		goal1.CFrame = CFrame.new(character:FindFirstChild("HumanoidRootPart").Position, Vector3.new(mouse.Hit.p.X, character:FindFirstChild("HumanoidRootPart").CFrame.Y, mouse.Hit.p.Z))
		
		local g1 = t:Create(character:FindFirstChild("HumanoidRootPart"), TweenInfo.new(0.5), goal1)
		g1:Play()
		
		local symbol = game:GetService("ReplicatedStorage").dontdisturbthis.PainMagicFiles.PainSymbol:Clone()
		symbol.Parent = game.Workspace
		symbol.CFrame = character:FindFirstChild("HumanoidRootPart").CFrame * CFrame.new(0,-3,0)
										remote:FireAllClients(symbol)

		
		local aol = {}
		aol.Size = Vector3.new(12, 0.05, 12)
		aol.Orientation = Vector3.new(0,character:FindFirstChild("HumanoidRootPart").Orientation.Y,0)
		
		local a1 = t:Create(symbol, TweenInfo.new(0.5), aol)
		a1:Play()
		
		local pain = game:GetService("ReplicatedStorage").dontdisturbthis.PainMagicFiles.Blood:Clone()
		pain.Parent = game.Workspace
		pain.CFrame = character:FindFirstChild("HumanoidRootPart").CFrame * CFrame.new(0,5,0)
		pain.Transparency = 1
										remote:FireAllClients(pain)

		
		local trans = {}
		trans.Transparency = 0
		
		local t1 = t:Create(pain, TweenInfo.new(0.5), trans)
		t1:Play()
		
		local attachment1 = Instance.new("Attachment")
		attachment1.Parent = pain
		
		local attachment0 = Instance.new("Attachment")
		attachment0.Parent = character:FindFirstChild("HumanoidRootPart")
		
		local beam = game:GetService("ReplicatedStorage").dontdisturbthis.PainMagicFiles.Bloodbeam:Clone()
		beam.Parent = pain
		beam.Attachment1 = attachment1
		beam.Attachment0 = attachment0
											remote:FireAllClients(beam)


		
		wait(1/3 + 1/2 - 0.4)
		print(1/3 + 1/2 - 0.4)
		
		animate = human:LoadAnimation(animation)
		animate:Play()
	
		
		wait(0.7)
		character:FindFirstChild("Humanoid").WalkSpeed = 16
		character:FindFirstChild("Humanoid").JumpPower = 50
		character:FindFirstChild("HumanoidRootPart").Anchored = false
	
		wait(0.1)
		
		local goal = {}
		goal.CFrame = character:FindFirstChild("HumanoidRootPart").CFrame * CFrame.new(0,24,-45)
		
		local g = t:Create(pain, TweenInfo.new(0.5), goal)
		g:Play() 
		
									local sound = game.ReplicatedStorage.dontdisturbthis.PainMagicFiles.Launch:Clone()
							
			sound.Parent = pain
			sound:Play()
					remote:FireAllClients(sound)

		
		wait(0.2)
		
		local goal2 = {}
		goal2.CFrame = CFrame.new(mouse.Hit.p.X,mouse.Hit.p.Y,mouse.Hit.p.Z)
	
		local g2 = t:Create(pain, TweenInfo.new(0.3), goal2)
		g2:Play()
				
		pain.Touched:Connect(function(hit)
			local hs = hit:FindFirstChild("Humanoid") or hit.Parent:FindFirstChild("Humanoid")
			if explosionlimit == 1 then
				explosionlimit = 2			
				print("yay")
				local expl = game:GetService("ReplicatedStorage").dontdisturbthis.PainMagicFiles.PainExplode:Clone()
				expl.Transparency = 0
				expl.Parent = workspace
				expl.CFrame = pain.CFrame * CFrame.new(0,0, 0)
				expl.Touched:Connect(function(hit)
					local hs = hit:FindFirstChild("Humanoid") or hit:FindFirstChildOfClass("Humanoid")
					if hs then 
						hs.PlatformStand = true
						hs:TakeDamage(10)
						wait(5)
						hs.PlatformStand = false
					end
				end)
														remote:FireAllClients(expl)


							local sound = game.ReplicatedStorage.dontdisturbthis.PainMagicFiles.Hit:Clone()
							
			sound.Parent = expl
			sound:Play()
														remote:FireAllClients(sound)

									
				local go = {}
				go.Size = Vector3.new(50,50,50)
				go.Transparency = 1
					
				local g1g = t:Create(expl, TweenInfo.new(0.5), go)
				g1g:Play()


				local gos = {}
				gos.Transparency = 1
					
				local g1sg = t:Create(expl.SelectionSphere, TweenInfo.new(3), gos)
				g1sg:Play()		
							
				pain:Destroy()
				wait(0.2)
				explosionlimit = 1
				wait(4)
				expl.SelectionSphere:Destroy()
				wait(5)	
				expl:Destroy()
				
				--if -- then	
					
				--end
				end
		end)
			
		pain.Anchored = false
		
		wait(1)
		pain:Destroy()
		
		local symb = {}
		symb.Size = Vector3.new(0.05,0.05,0.05)

		local sy1 = t:Create(symbol, TweenInfo.new(0.2), symb)
		sy1:Play()		
		
		wait(1)
		symbol:Destroy()
		
		wait(4)
		
		
		cooldown = true
		end
		if mana.Value <= 100 then
			script.Parent.Parent.MagicEnergy.TextLabel.TextColor3 = Color3.fromRGB(255, 0, 0)
			wait(0.5)
			script.Parent.Parent.MagicEnergy.TextLabel.TextColor3 = Color3.fromRGB(255, 255, 255)
			wait(0.5)
			script.Parent.Parent.MagicEnergy.TextLabel.TextColor3 = Color3.fromRGB(255, 0, 0)
			wait(0.5)
			script.Parent.Parent.MagicEnergy.TextLabel.TextColor3 = Color3.fromRGB(255, 255, 255)			
		end
		end
		
	end)
	end)		

So somebody can explain and say the replacement instead of re-scripting it? Also if you want to re-script it just don't include the Cloning, Table and Tweening stuffs.

2 comments

1

I have no idea why you have put everything inside this one event and use FireAllClients in the OnClientEvent ??

0

I haven't know what to use :/

1 answer

You are using FireAllClients() in the OnClientEvent.. It's repeating itself, it's an infinite loop. That's what I think, because I am also new at RemoteEvents and functions.

3 comments

0

So I have to use FireServer/FireClient instead?

0

Well, I will take a look at your script, because it takes a long time to read all the 200+ lines.

0

Dude sorry I am busy that I can't just re-script your script. Sorry, please try look up your issue, try watching videos on what you want to do..

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