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

How can I make this script run on both the client and the server simultaneously?[FilteringEnabled] [closed]

Asked by 6 years ago
Edited 6 years ago
01local generator = script.Parent.Parent
02local hum = script.Parent
03local StatusGUI = generator.StatusGUI
04local bar = StatusGUI.background.bar
05local bar2 = StatusGUI.background.bar2
06 
07local recharge = script.recharge
08 
09function status()
10bar:TweenSize(UDim2.new(hum.Health/hum.MaxHealth,0,1,0, "Out","Quad"))
11    StatusGUI.background.title.Text = generator.Name   
12        if hum.Health >= 0.7 * hum.MaxHealth then
13            bar.BackgroundColor3 = Color3.fromRGB(0,255,0)
14        elseif hum.Health < 0.7 * hum.MaxHealth and hum.health > 0.5 * hum.MaxHealth then
15            bar.BackgroundColor3 = Color3.fromRGB(255,255,0)
View all 40 lines...
0
What does your nice script do StateSector 8 — 6y
0
Basically, I'm a clanscrub. I'm building Force Field Generators for my Clan Valkan. They're a crucial part of my Raid System that I am working on from scratch. The Generator script does work in Server Mode but I need it to also work in Client Mode. Inevitable_Judgement -10 — 6y

Closed as Too Broad by User#24403, Leamir, zblox164, and DinozCreates

This question has been closed because it is too broad and is generally unanswerable. Please ask a more specific question.

Why was this question closed?

1 answer

Log in to vote
0
Answered by
Radstar1 270 Moderation Voter
6 years ago
Edited 6 years ago

Okay revising my answer now based on what you have told me.

So inorder to fix the client not seeing it as an animate objects you might have to get rid of that humanoid and make your own 'fake humanoid' How I would do this is insert two NumberValuethat represents the MaxHealth and Health into the Generator.

So the MaxHealth would be like 10 and then whenever someone attacks the generator the health keeps going down from there. As for the regeneration of the Health you would just use your while loop and make the Health increase until it reaches max health.

You would have to connect that health to the status's health. From there you can make it to where whenever the player attacks the Generator, the numbervalue changes, and when that number value changes the billboard gui changes as well.

If you want the player to be able to interact with a Billboard Gui it must be in the startergui. If not you can just leave it inside of the generator.

Make sure the billboardgui is in the StarterGui folder as so: --Only if the player can edit it https://gyazo.com/8af0b7e47975d72f66f9f6a0681ea4b1

1) Inside of the player, you would put a localscript and inside of it make sure that everytime the generator's health changes the player recognizes it.

EX:

01local Plr = game.Players.LocalPlayer
02repeat wait() until Plr.Character
03local Char = Plr.Character
04local Hum = Char:WaitForChild('Humanoid')
05local Generator = --where the generator is located in workspace or wherever
06local GenHumanoid = Generator.Humanoid
07local StatusGui = StarterGui.StatusGUI
08function status ()
09--blah blah
10end
11GenHumanoid.HealthChanged:Connect(function()
12    Status()
13end)

This will connect you locally to your generator's humanoid. The player can change the generator's health from the client by exploiting but it won't be updated to the server. That being said the change in health that player may see from doing so won't be the ACTUAL health.

0
Let me explain what this script does. So the script is part of a Generator I built that is supposed to be destroyable by Raiders. The Humanoid I am targetting is the one within the Generator, not the player. Problem is, when I play in Client Mode the script doesn't work, but when I run it in Server mode it does. Inevitable_Judgement -10 — 6y
0
The script is actually inside the Humanoid that's in the Generator. I felt using a Humanoid was the best course of action to make an Object have health Inevitable_Judgement -10 — 6y
0
so what exactly is happening on the server that's not replicating to the client? Radstar1 270 — 6y
0
The entire script works in the server, but not the client. The client just sees it as an inanimate object. Inevitable_Judgement -10 — 6y
View all comments (5 more)
0
Okay I'm changing my previous answer to what you might need. I think you may need to create your own fake humanoid. Radstar1 270 — 6y
0
Okay that should hopefully have solved your answer Radstar1 270 — 6y
0
please upvote if it helped ;) Radstar1 270 — 6y
0
So apparently, I didn't need to do anything to the script above. For some reason it worked just fine in an actual place visit. But not in the studio. So I am guessing it'll be fine...Thank you! Inevitable_Judgement -10 — 6y
0
glad everything is working fine then, enjoy!! Radstar1 270 — 6y
Ad