What solutions have you tried so far?
tried to search many times on dev forum nothing helped
local ts = game:GetService("TweenService")
local Ss = game:GetService("ServerStorage")
local Players = game:GetService("Players")
local Player = Players.LocalPlayer --Error happening in this line
local Gui = Player:WaitForChild("PlayersGui")
local Base = {}
function Base.Setup(Health,ui)
Base.HealthUI = Players.LocalPlayer.PlayerGui.Canvas.Upperinfo["Base Health"]
Base.CurrentHealth = Health
Base.MaxHealth = Health
end
function Base.DamageBase(damage)
if damage then
Base.CurrentHealth -= damage
local gui = Base.HealthUI
local tweeninfo = TweenInfo.new(
0.5,
Enum.EasingStyle.Exponential,
Enum.EasingDirection.In,
0,
false,
0
)
local percentage = Base.CurrentHealth/Base.MaxHealth
local goal = {}
goal.Size = UDim2.new(percentage,0,0.25,0)
local tween = ts:Create(gui.CurrentHealth,tweeninfo,goal)
tween:Play()
gui.Title.Text = ("Base Health: ") .. (Base.MaxHealth) .. ("|") .. (Base.CurrentHealth)
if Base.CurrentHealth <= 0 then
gui.Title.Text = ("Base Health: OOF")
Ss.Bindables.GameOver:Fire()
end
end
end
Ss.Bindables.DamageBase.Event:Connect(Base.DamageBase)
return Base
If you’re requiring this module on the server, it simply wouldn’t work, since Players.LocalPlayer is a field only available to the client (LocalScripts)
I suggest you pass the player as a parameter/argument to the function. That’d work.
it was a long video but it was around the first timelapse around 3-10 mins note sure but may be mine didnt worked cuz i missed some steps becuase he was using bill board gui which i didnt wanted to use. 1 hour passed still waiting
You are probably requiring the wrong module, because this module needs to be required by the client, not by the server. Check if you got the name of the module right for both the instance and the script.
local Base = require(script.Base)
local mob = require(script.Mob)
local Unit = require(script.Unit)
local map = workspace.Grassland
local Ss = game:GetService(“ServerStorage”)
local rs = game:GetService(“ReplicatedStorage”)
local players = game:GetService(“Players”)
local PhysicsService = game:GetService(“PhysicsService”)
local ts = game:GetService(“TweenService”)
local GameOverEvent = Ss.Bindables:WaitForChild(“GameOver”)
local GameOver = false
for wave =1, 100 do
print(“WAVE STARTING:”, wave)
if wave < 100 then
mob.Spawn(“TankEnemy”, 300 * wave,map)
end
repeat
task.wait(1)
until #workspace.Mobs:GetChildren() == 0 or GameOver
if GameOver then
print("Game Over")
break
end
print("WAVE ENDED")
task.wait(1)
end
heres a script of thats requiring most of the modules
and i already gave the base module
idk whats wrong all spellings are correct
and its still a server script btw
local ts = game:GetService("TweenService")
local Ss = game:GetService("ServerStorage")
local Player = game:GetService("Players").LocalPlayer
local Gui = Player:WaitForChild("PlayerGui")
local Base = {}
function Base.Setup(Health,ui)
Base.HealthUI = Gui.Canvas.Upperinfo["Base Health"]
Base.CurrentHealth = Health
Base.MaxHealth = Health
end
function Base.DamageBase(damage)
if damage then
Base.CurrentHealth -= damage
local gui = Base.HealthUI
local tweeninfo = TweenInfo.new(
0.5,
Enum.EasingStyle.Exponential,
Enum.EasingDirection.In,
0,
false,
0
)
local percentage = Base.CurrentHealth/Base.MaxHealth
local goal = {}
goal.Size = UDim2.new(percentage,0,0.25,0)
local tween = ts:Create(gui.CurrentHealth,tweeninfo,goal)
tween:Play()
gui.Title.Text = ("Base Health: ") .. (Base.MaxHealth) .. ("|") .. (Base.CurrentHealth)
if Base.CurrentHealth <= 0 then
gui.Title.Text = ("Base Health: OOF")
Ss.Bindables.GameOver:Fire()
end
end
end
Ss.Bindables.DamageBase.Event:Connect(Base.DamageBase)
return Base
If you’re requiring it on the server, then LocalPlayer doesn’t exist, LocalPlayer is only accessible on the client, so if you require the module on a server script, it wont find anything, but if you require it on a Local script it will find it.