Works when Im in a server by my self, otherwise "fireball" stays still visibly but does damage?
Asked by
6 years ago Edited 6 years ago
This was working fine a while ago, but after I tried too expand with other ability ideas, I think I tinkered with something I should have, and stupidly didn't save.I also think I might be using something outdated. I can shoot out the "fireball" but when in a game with other people,it doesn't move but still hits as if it was moving. Thanks for any help (:
In serverscriptservice as regular script
01 | local ReplicatedStorage = game:GetService( "ReplicatedStorage" ) |
02 | local Debris = game:GetService( 'Debris' ) |
05 | local Remote = ReplicatedStorage.FireBallEvent |
06 | local FireBall = ReplicatedStorage.FireBall |
11 | local ServerDebounces = { } |
12 | FireBall.Transparency = 0.5 |
13 | FireBall.CanCollide = false |
14 | Remote.OnServerEvent:Connect( function (plr, Mouse) |
15 | if not ServerDebounces [ plr ] then |
16 | ServerDebounces [ plr ] = true |
18 | local Char = plr.Character or plr.CharacterAdded:Wait() |
20 | local FireBallClone = FireBall:Clone() |
21 | FireBallClone.CFrame = Char.HumanoidRootPart.CFrame * CFrame.new( 0 , 0 ,- 3 ) |
22 | FireBallClone.Parent = workspace |
24 | local BodyVelocity = Instance.new( "BodyVelocity" ) |
25 | BodyVelocity.MaxForce = Vector 3. new( math.huge , math.huge , math.huge ) |
26 | BodyVelocity.Velocity = Mouse.lookVector |
27 | BodyVelocity.Parent = FireBallClone |
32 | FireBallClone.Size = FireBallClone.Size + Vector 3. new( 0.25 , 0.025 , 0.025 ) |
33 | BodyVelocity.Velocity = Mouse.lookVector* 100 |
36 | ServerDebounces [ plr ] = false |
37 | Debris:AddItem(FireBallClone, 10 ) |
40 | FireBallClone.Touched:Connect( function (h) |
41 | if h.Parent:FindFirstChild( 'Humanoid' ) and h.Parent.Name ~ = plr.Name and Debounce then |
43 | local Enemy = h.Parent.Humanoid |
44 | Enemy:TakeDamage(Damage) |
45 | FireBallClone.Transparency = 1 |
47 | FireBallClone.Effect.Speed = NumberRange.new( 8 , 8 ) |
49 | FireBallClone.Effect.Enabled = false |
51 | FireBallClone:Destroy() |
In Starter GUI as local script
01 | local ReplicatedStorage = game:GetService( "ReplicatedStorage" ) |
02 | local UserInputService = game:GetService( "UserInputService" ) |
04 | local plr = game.Players.LocalPlayer |
05 | local Char = plr.Character or plr.CharacterAdded:Wait() |
06 | local Remote = ReplicatedStorage.FireBallEvent |
07 | local Mouse = plr:GetMouse() |
11 | local Animation = Instance.new( "Animation" ) |
14 | UserInputService.InputBegan:Connect( function (Input, IsTyping) |
15 | if IsTyping then return end |
16 | local KeyPressed = Input.KeyCode |
17 | if KeyPressed = = Enum.KeyCode [ Key ] and Debounce and Char then |
19 | Remote:FireServer(Mouse.Hit) |
20 | local LoadAnimation = Char.Humanoid:LoadAnimation(Animation) |
thanks again