Roblox problem or mine?

Im making a roblox rpg, and I have made a charged attack, I also made a normal attack.
Now the normal attack works, but the charged attack doesnt (they have identical script, i only added the charge feature to the charged one)

Here is the local script error :

fireBall.Touched:Connect(function(hit)
		if hit:IsDescendantOf(CastingCharacter) or hit:FindFirstChild("ParticleEmitter") then return end
		explosion.Position = fireBall.Position
		fireBall:Destroy()
		explosion.Parent = workspace
		explosion.Sound:Play()
		if caster == player then 
			game.ReplicatedStorage.Events.ChargedFireBall:FireServer(hit) -- doesnt work (Problem)
		end
		print("FireBall2 Touched") -- Prints
		wait(1)
		explosion:Destroy()
	end)
end

Here is the server script :

game.ReplicatedStorage.Events.ChargedFireBall.OnServerEvent:Connect(function(player, part, mousePos)
	print("6") -- doesnt print
	if part == "NewFireBall2" then
		print("7") -- doesnt print
		game.ReplicatedStorage.Events.ChargedFireBall:FireAllClients(player, mousePos)
		print("8") -- doesnt print
	elseif part.Parent.Humanoid then
		print("9") -- doesnt print
		part.Parent.Humanoid:TakeDamage(50)
		print("10") -- doesnt print
	end
end)

It seems that the event in the local script doesnt fire, but it still continues on the script, and idk how to fix it and make it fire, because the server script doesnt print a thing and just doesnt do anything

here is the full local script if you need to read it:

local UIS = game:GetService("UserInputService")
local debounce = false
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
local Charging = false
local debounce = false
local runservice = game:GetService("RunService")
local rayCastParams =RaycastParams.new()

---- Camera Aim
local Camera = game.Workspace.CurrentCamera
local player = game.Players.LocalPlayer
local Character = player.Character 
local rootPart = Character:FindFirstChild("HumanoidRootPart")
local mouse = player:GetMouse()
local aim = false
local runService = game:GetService("RunService")
local CanRun = game.Players.LocalPlayer:FindFirstChild("PlayerValueFolder"):WaitForChild("CanRun")

runService.RenderStepped:Connect(function()
	if aim == true then
	local rx, ry, rz = Camera.CFrame:ToOrientation()
	rootPart.CFrame = CFrame.new(rootPart.CFrame.p) * CFrame.fromOrientation(0, ry, 0)
	end

end)

----
local function shootFireball(caster, mousePos)
	if caster == player then
		game.ReplicatedStorage.Events.ChargedFireBall:FireServer("NewFireBall2", mousePos)
	end

	local Effects = game.ReplicatedStorage.FireballEffects
	local fireBall = Effects.Fire:Clone()
	local explosion = Effects.Explosion2:Clone()
	local CastingCharacter = character


	fireBall.Position = CastingCharacter["Right Arm"].Position
	fireBall.Parent = game.workspace
	fireBall.Sound:Play()
	local weld = Instance.new("WeldConstraint", fireBall)
	weld.Part0 = fireBall
	weld.Part1 = CastingCharacter["Right Arm"]
	wait(0.45)
	weld:Destroy()
	local MousePosition = mousePos
	local velocity = Instance.new("BodyVelocity", fireBall)
	velocity.Velocity = CFrame.new(fireBall.Position, mouse.Hit.p).LookVector * 100


	fireBall.Touched:Connect(function(hit)
		if hit:IsDescendantOf(CastingCharacter) or hit:FindFirstChild("ParticleEmitter") then return end
		explosion.Position = fireBall.Position
		fireBall:Destroy()
		explosion.Parent = workspace
		explosion.Sound:Play()
		if caster == player then 
			game.ReplicatedStorage.Events.ChargedFireBall:FireServer(hit)
		end
		print("FireBall2 Touched")
		wait(1)
		explosion:Destroy()
	end)
end


UIS.InputBegan:Connect(function(input, gameProccesedEvent)
	if input.KeyCode == Enum.KeyCode.R and Charging == false and not debounce then
		Charging = true
		debounce = true
		aim = true
		CanRun.Value = false
		
		local animationTrack = humanoid:LoadAnimation(script.StartCharging)
		animationTrack:Play()

		animationTrack.Stopped:Wait()
		
		local NewFireEffect = Instance.new("Fire")
		NewFireEffect.Parent = character["Right Arm"]
		humanoid.WalkSpeed = 0
		
		local animationTrack2 = humanoid:LoadAnimation(script.Charging)
		animationTrack2:Play()
		
		wait(1)
		debounce = false
	elseif input.KeyCode == Enum.KeyCode.R and Charging == true and debounce == false then
		debounce = true
		
		for i,v in pairs(player.Character.Humanoid:GetPlayingAnimationTracks()) do
			v:Stop()
		end
		
		--
		--shootFireball()
		shootFireball()
		
		local animationTrack3 = humanoid:LoadAnimation(script.Throw)
		animationTrack3:Play()
		animationTrack3.Stopped:Wait()
		wait(1)
		humanoid.WalkSpeed = 16
		character["Right Arm"]:FindFirstChildWhichIsA("Fire"):Destroy()
		
		aim = false
		Charging = false
		CanRun.Value = true
		wait(4)
		debounce = false
	end
end)
1 Like

In the server script, you’re getting the actual part and the mouse pos, you’re only sending the mouse pos

Secondly, if it’s the object you’re sending, surely you’d need part.Name == “NewFireBall2”

Hope it helps

1 Like

Thanks, I fixed it but the problem was weird, all I changed was player = plr???
roblox is weird sometimes

You’re repeating some variables in your script, you don’t need to repeat the player value again

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.