01 | local UserInput = game:GetService( "UserInputService" ) |
02 | local offset = Vector 3. new( 0 , 0 ,- 3 ) |
03 | local player = game.Players.LocalPlayer |
04 | local Character = player.Character or player.CharacterAdded:wait() |
05 | local rootpart = Character:WaitForChild( "HumanoidRootPart" , 3 ) |
06 | local FireBallEvent = game.ReplicatedStorage.FireBallEvent |
07 |
08 | UserInput.InputBegan:connect( function (input) |
09 | if input.KeyCode = = Enum.KeyCode.R then |
10 | print ( "You pressed R" ) |
11 | local CreateFireBall = Instance.new( "Part" , workspace) |
12 | CreateFireBall.Shape = "Ball" |
13 | CreateFireBall.Size = Vector 3. new( 5 , 5 , 5 ) |
14 | CreateFireBall.Anchored = true |
15 | CreateFireBall.CanCollide = true |
that is the server script, the event is call FireBallEvent
1 | local FireBallEvent = game.ReplicatedStorage.FireBallEvent |
2 |
3 | FireBallEvent.OnServerEvent:Connect( function (player, character) |
4 | character.Humanoid.Health = character.Humanoid.Health - 5 |
5 | end ) |
and that is the local script, for some reason this wont work help! The fireball comes out and moves but it doesnt do damage upon hitting a dummy. No errors come up either
bruh i see the problem in ur server script the server thinks character is the player u should write Player.Character instead and u dont need to apply any name to the FireServer() as the player who fires the server is already outputted like example script in last part of local script (Also u need to put touch in server or wont work
01 | UserInput.InputBegan:connect( function (input) |
02 | if input.KeyCode = = Enum.KeyCode.R then |
03 | print ( "You pressed R" ) |
04 | local CreateFireBall = Instance.new( "Part" , workspace) |
05 | CreateFireBall.Shape = "Ball" |
06 | CreateFireBall.Size = Vector 3. new( 5 , 5 , 5 ) |
07 | CreateFireBall.Anchored = true |
08 | CreateFireBall.CanCollide = true |
09 | CreateFireBall.BrickColor = BrickColor.new( "Really red" ) |
10 | CreateFireBall.CFrame = rootpart.CFrame * CFrame.new(offset) |
11 | FireBallEvent:FireServer(CreateFireBall) |
12 |
13 | local Veloc = instance.New( "Body Velocity" ,CreateFireBall) |
14 | Veloc.Velocity = game.Player.LocalPlayer.Character.Torso.CFrame.LookVector * 60 |
15 | -- You can use a body velocity here instead of the offset like |
and for ur server script
01 | local FireBallEvent = game.ReplicatedStorage.FireBallEvent |
02 |
03 | FireBallEvent.OnServerEvent:Connect( function (player,part) |
04 | local tr = true |
05 | local E = true |
06 | wait ( 0.2 ) -- incase it touches twice and deals double dmg |
07 | local tr = true |
08 | part.Touched:connect( function (OtehPart) |
09 | if OtehPart.Parent:FindFirstChild( "Humanoid" ) and E and tr then |
10 | OtehPart.Parent.Humanoid:TakeDamage( 5 ) |
11 |
12 |
13 | end ) |
i hoped this helped