Localscript, you can put it inside PlayerGui, StarterPack, StarterPlayerScripts, StarterCharacterScripts
local player = game.Players.LocalPlayer
local uis = game:GetService("UserInputService")
local db = true
uis.InputBegan:Connect(function(input, playerIsChatting)
if input.KeyCode == Enum.KeyCode.E then
if not playerIsChatting then
if db then
db = false
workspace.FireballEvent:FireServer()
wait(5)
db = true
end
end
end
end)
now put RemoteEvent inside Workspace and Server side script (normal script) inside RemoteEvent
Server script
script.Parent.OnServerEvent:Connect(function(player)
local fireBall = game.ReplicatedStorage.Ball:Clone()
local char = player.Character or player.CharacterAdded:Wait()
local HRP = char:WaitForChild("HumanoidRootPart")
fireBall.Parent = workspace
fireBall.Position = HRP.Position
local bodyV = Instance.new("BodyVelocity", fireBall)
bodyV.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
bodyV.Velocity = HRP.CFrame.LookVector * 120
local hitDb = true
fireBall.Touched:Connect(function(hit)
if hit:IsA("BasePart")then
if not hit:IsDescendantOf(char) then
if hitDb then
hitDb = false
if hit.Parent:FindFirstChild("Humanoid") then
local Ehum = hit.Parent.Humanoid
fireBall:Destroy()
Ehum:TakeDamage(20)
end
end
end
end
end)
wait(5)
fireBall:Destroy()
hitDb = true
end)