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

when i activate my script nothing happens can you fix it?

essentially the melee attack isnt doing anything i press e and nothing happens its like the script doesnt run


--//Titan Shift

script.Parent.Shift.OnServerEvent:Connect(function(Player)
	
	
	NewChar = game.ReplicatedStorage.BasicAttackTitan:Clone()
	local Pos = Player.Character:GetPrimaryPartCFrame()
	
	Player.Character:Destroy()
	Player.Character = NewChar
	NewChar.Parent = workspace
	NewChar:SetPrimaryPartCFrame(Pos)
end)

--//Melee Attack

local Attack1 = script.Attack1
local Attack2 = script.Attack2
local ComSeq = 1
local anim
local Hitbox = game.ServerStorage.HitBox


script.Parent.Melee.OnServerEvent:Connect(function()
	
	
	print(NewChar)
	
	local hum = NewChar.Humanoid
	local Humrp = NewChar.HumanoidRootPart
		local anim1 = hum:LoadAnimation(Attack1)
		local anim2 = hum:LoadAnimation(Attack2)



		if ComSeq == 1 then
			anim = anim1
			ComSeq = 2

		elseif ComSeq == 2 then
			anim = anim2
			ComSeq = 1

		end

		anim:Play()

		local HitboxNew = Hitbox:Clone()
		local Weld = Instance.new("WeldConstraint")
		Weld.Parent = Humrp
		Weld.Part0 = Humrp
		Weld.Part1 = HitboxNew

		HitboxNew.CFrame = Humrp.CFrame * CFrame.new(0,0,-3)
		HitboxNew.Parent = Humrp

		local touchConn

		touchConn = HitboxNew.touched:Connect(function(hit)
		if hit.Parent.Name ~= NewChar.Name and hit.Parent.Humanoid then

				HitboxNew:Destroy()
				Weld:Destroy()
				hum.Health -= 100

			end	
		end)
		wait(0.5)
		if touchConn ~= nil then touchConn:Disconnect() end
		Weld:Destroy()
		HitboxNew:Destroy()
end)

1 answer

This is a local script. It is trying to do things such as destroy parts in the workspace. However, local scripts cannot do this without a remote function, which is, in a nutshell, what filtering enabled scripting is. Search up a tutorial on remote functions and remote events and it should help you with your script.

1 comment

0

how can this be true though? it says onserverevent meaning its in a server script

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