How do I properly implement remoteEvents or functions into this script? [closed]
Asked by
6 years ago Edited 6 years ago
So this script is a script I made from scratch for a Boss' AI, everything works on the server side but on the client it's different, everything the boss does, for example when he regenerates his health, the change is being made on the server, but players cannot see it so therefore, he hasn't regenerated any lost health as far as the player is concerned. I want all Clients to see his actions.
02 | hum = script.Parent.hum |
04 | actionEvent = Instance.new( "RemoteEvent" ) |
05 | actionEvent.Parent = game.ReplicatedStorage |
09 | actions = { "REST" , "REGEN" , "ROCKET" } |
16 | hum.Health = hum.Health+ 1 |
18 | until i = = 1 / 4 *hum.MaxHealth |
22 | local projectile = Instance.new( "Part" ) |
23 | projectile.Parent = workspace |
24 | projectile.Name = "projectile" |
25 | projectile.Material = "Neon" |
26 | projectile.Size = Vector 3. new( 1 , 1 , 2 ) |
27 | projectile.CFrame = script.Parent.Torso.CFrame*CFrame.new( 0 , 0 ,- 5 ) |
28 | local BV = Instance.new( "BodyVelocity" ) |
30 | BV.MaxForce = Vector 3. new( math.huge , math.huge , math.huge ) |
31 | BV.Velocity = script.Parent.Torso.CFrame.LookVector* 100 |
32 | local Dmg = script.rocketDmg:Clone() |
33 | Dmg.Parent = projectile |
38 | actionEvent:FireAllClients() |
39 | action = actions [ math.random( 1 ,#actions) ] |
41 | if action = = "REGEN" then |
43 | elseif action = = "ROCKET" then |
I'm having a similar problem with the Damage Script for the Rocket. The Rocket is supposed to explode on Impact.
02 | local ex = Instance.new( "Explosion" ) |
03 | ex.Parent = script.Parent |
04 | ex.Position = script.Parent.Position |
05 | script.Parent:Destroy() |
07 | script.Parent.Touched:Connect(Hit) |
10 | script.Parent:Destroy() |
Any help would be appreciated.