Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
2

FireBall script trying to make it so that it does damage when it touches but it doesnt?

Asked by
Glacitron 239 Moderation Voter
5 years ago
01local UserInput = game:GetService("UserInputService")
02local offset = Vector3.new(0,0,-3)
03local player = game.Players.LocalPlayer
04local Character = player.Character or player.CharacterAdded:wait()
05local rootpart = Character:WaitForChild("HumanoidRootPart",3)
06local FireBallEvent = game.ReplicatedStorage.FireBallEvent
07 
08UserInput.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 = Vector3.new(5,5,5)
14        CreateFireBall.Anchored = true
15        CreateFireBall.CanCollide = true
View all 29 lines...

that is the server script, the event is call FireBallEvent

1local FireBallEvent = game.ReplicatedStorage.FireBallEvent
2 
3FireBallEvent.OnServerEvent:Connect(function(player, character)
4    character.Humanoid.Health = character.Humanoid.Health -5
5end)

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

0
You can't have a LocalScript change something that should show in the server Spjureeedd 385 — 5y

1 answer

Log in to vote
0
Answered by
TNTIsLyfe 152
5 years ago
Edited 5 years ago

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

01UserInput.InputBegan:connect(function(input)
02if 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 = Vector3.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)
11FireBallEvent:FireServer(CreateFireBall)
12 
13                local Veloc = instance.New("Body Velocity",CreateFireBall)
14Veloc.Velocity = game.Player.LocalPlayer.Character.Torso.CFrame.LookVector * 60     
15            -- You can use a body velocity here instead of the offset like
View all 21 lines...

and for ur server script

01local FireBallEvent = game.ReplicatedStorage.FireBallEvent
02 
03FireBallEvent.OnServerEvent:Connect(function(player,part)
04    local tr = true
05local E = true
06wait (0.2) -- incase it touches twice and deals double dmg
07local tr = true
08part.Touched:connect(function(OtehPart)
09if OtehPart.Parent:FindFirstChild("Humanoid") and E and tr then
10OtehPart.Parent.Humanoid:TakeDamage(5)
11 
12 
13end)

i hoped this helped

Ad

Answer this question