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

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.

-- Attack Script
hum = script.Parent.hum

actionEvent = Instance.new("RemoteEvent")
actionEvent.Parent = game.ReplicatedStorage

players = game.Players

actions = {"REST","REGEN","ROCKET"}

function regen()
local i=1
repeat
wait(0.2)
i=i+1
hum.Health=hum.Health+1
print(i)
until i==1/4*hum.MaxHealth
end

function rocket()
local projectile = Instance.new("Part")
projectile.Parent = workspace
projectile.Name = "projectile"
projectile.Material = "Neon"
projectile.Size = Vector3.new(1,1,2)
projectile.CFrame = script.Parent.Torso.CFrame*CFrame.new(0,0,-5)
local BV = Instance.new("BodyVelocity")
BV.Parent = projectile
BV.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
BV.Velocity = script.Parent.Torso.CFrame.LookVector*100
local Dmg = script.rocketDmg:Clone()
Dmg.Parent = projectile
Dmg.Disabled = false
end

while wait(5) do
actionEvent:FireAllClients()
action=actions[math.random(1,#actions)]
print(action)
if action=="REGEN" then
regen()
elseif action== "ROCKET" then
rocket()
end
end

I'm having a similar problem with the Damage Script for the Rocket. The Rocket is supposed to explode on Impact.

function Hit()
local ex = Instance.new("Explosion")
ex.Parent = script.Parent
ex.Position = script.Parent.Position
script.Parent:Destroy()
end
script.Parent.Touched:Connect(Hit)

wait(10)
script.Parent:Destroy()

Any help would be appreciated.

0
i thought any changes made on the server would be automatically replicated to the client? no? GoldAngelInDisguise 297 — 6y
0
That's how it used to work, before they changed how the server communicates with the client. Inevitable_Judgement -10 — 6y
0
I don't see why this change was made, I'll have to read up about that later on. Thanks for the info. xEmmalyx 285 — 6y

Closed as Primarily Opinion-Based by User#24403, DinozCreates, Gey4Jesus69, SummerEquinox, and evaera

This question has been closed because it is a discussion about a topic focused on diverse opinions, which isn't a good fit for our Q&A format.

Why was this question closed?