I need help changing this to a normal script because when I press Q I only take damage and not others. I just want them to take damage.
wait(3) UserInputService = game:GetService("UserInputService") local players = game:GetService("Players") local dash = script:WaitForChild("Dash") local localPlayer = players.LocalPlayer local tween = game:GetService("TweenService") local humanoid = localPlayer.Character:WaitForChild("Humanoid") local humRootPart = humanoid.Parent:WaitForChild("HumanoidRootPart") local info1 = TweenInfo.new( 1.3, Enum.EasingStyle.Quint, Enum.EasingDirection.Out, 0, false, 0 ) local info2 = TweenInfo.new( 0.1, Enum.EasingStyle.Quint, Enum.EasingDirection.Out, 0, false, 0 ) local db = false local db2 = false local db3 = false local makeTrail = function(A0, A1, Parent, Transparency, Lifetime) local t = Instance.new("Trail", Parent) t.Color = ColorSequence.new(Color3.new(255, 255, 255), Color3.new(255, 255, 255)) local a0 = Instance.new("Attachment", A0) local a1 = Instance.new("Attachment", A1) t.Attachment0 = a0 t.Attachment1 = a1 t.Transparency = NumberSequence.new(Transparency) t.Lifetime = Lifetime end UserInputService.InputBegan:Connect(function(input, gameProccesedEvent) if input.KeyCode == Enum.KeyCode.E and db == false then db = true local endPos = { CFrame = humRootPart.CFrame:ToWorldSpace(CFrame.new(0, 0, -60)) } local animation = humanoid:LoadAnimation(dash) local move = tween:Create(humRootPart, info1, endPos) animation:Play() move:Play() makeTrail(localPlayer.Character:FindFirstChild("RightUpperArm"), localPlayer.Character:FindFirstChild("RightHand"), localPlayer.Character, 0.7, 0.2) makeTrail(localPlayer.Character:FindFirstChild("LeftUpperArm"), localPlayer.Character:FindFirstChild("LeftHand"), localPlayer.Character, 0.7, 0.2) wait(0.5) localPlayer.Character.RightUpperArm.Attachment:Destroy() localPlayer.Character.LeftUpperArm.Attachment:Destroy() localPlayer.Character.RightHand.Attachment:Destroy() localPlayer.Character.LeftHand.Attachment:Destroy() localPlayer.Character:FindFirstChild("Trail"):Destroy() wait(0.5) db = false end end) UserInputService.InputBegan:Connect(function(input, gameProccesedEvent) if input.KeyCode == Enum.KeyCode.Q and db2 == false then db2 = true local burst = humanoid:LoadAnimation(script:FindFirstChild("Dash")) burst:Play() local b = Instance.new("Part", game.Workspace) b.Name = "Blast" b.BrickColor = BrickColor.new("New Yeller") b.Shape = Enum.PartType.Ball b.TopSurface = Enum.SurfaceType.Smooth b.BottomSurface = Enum.SurfaceType.Smooth b.Anchored = true b.CanCollide = false b.Material = Enum.Material.Neon b.Transparency = 0.7 for i = 1, 20, 2 do b.Size = Vector3.new(i, i, i) b.CFrame = humRootPart.CFrame wait() end humanoid:TakeDamage(20) b:Destroy() wait(1) db2 = false end end)
You cannot completely convert the script to server script because UserInputService doesn't work on server scripts. What you can do instead is insert a RemoteEvent in workspace and a normal script in the remote event.
In the script you have given, you should do like:
UserInputService.InputBegan:Connect(function(input, gameProccesedEvent) workspace.RemoteEvent:FireServer(input.KeyCode) end)
In this way, the KeyCode will be transferred to the normal script. Then, you can script the rest in the normal script like:
script.Parent.OnServerEvent:connect(function(plr, KeyCode) -- the "plr" is the player who pressed the key -- the "KeyCode" is the key the player pressed if KeyCode == Enum.KeyCode.E then -- script what happens when player presses E elseif KeyCode == Enum.KeyCode.Q then -- script what happens when player presses Q end end)
I hope this helps
Just copy the entire script and add a normal script and delete the local and paste it into the normal script