#RemoteEvent exhausted while having wait()
164 messages · Page 1 of 1 (latest)
Just dont make the remote event exhausted then
how much more do you want
nope
i cant get those variables from a script i need to send them through a remoteevent
what do i do then
Error is not here
Send the full snippets of when you trigger the remote event
Alr
Oh that's you again !
No
Instead, fire the server when the property of the image xhanges
You can use GetPropertyChangedSignal
On your imagelabel
To listen the Image property
And also, I highly recommend to create a remote event for each player if your game allows a lot of player to join
Singleplayer
Like this?
Pog
it isnt talking anymore
Although
The light doesnt actually spawn
** You are now Level 8! **
No
This is what should happen but the light doesnt go to that position
And it gives 0 errors
Paul can you help me?
Back
Want me to show my explorer?
[Heartbeat]
UpdateBattery()
end)
local function UpdateBatteray(battery)
local result = nil
for i = 0, 100, 25 do
result = batteryImages[i]
if i >= battery then break end
end
imageLabel.Image = result
end
this is what you have right ?
and then you added
function UpdateBattery(battery)
assert(type(battery) == "number")
local result = nil
for i = 0, 100, 25 do
result = batteryImages[i]
if i >= battery then break end
end
print(math.round(battery), Toggle)
imageLabel.Image = result
end
this
[Heartbeat]
UpdateBattery()
end)
local function UpdateBatteray(battery)
local result = nil
for i = 0, 100, 25 do
result = batteryImages[i]
if battery ~= 0 then
positionFlash:FireServer(true, Clone, Mouse, cam)
else
positionFlash:FireServer(false, Clone, Mouse, cam)
end
if i >= battery then break end
end
imageLabel.Image = result
end
yes and you added the if ... then
now first lets just clean that a bit
RunService.RenderSteeped:Connect(function()
UpdateBattery()
end)
local function UpdateBatteray(battery)
local result = nil
for i = 0, 100, 25 do
result = batteryImages[i]
positionFlash:FireServer(battery ~= 0, Clone, Mouse, cam)
if i >= battery then break end
end
imageLabel.Image = result
end
there you go
alright so now
i did this ```lua
RunService.RenderStepped:Connect(function()
UpdateBattery(battery)
imageLabel:GetPropertyChangedSignal("Image"):Connect(function()
positionFlashlight:FireServer(Toggle, Mouse, cam)
end)
if Toggle then
battery = math.max(battery - drainRate)
end
end)
yes then go back to the old verion
to this4
now instead of this
Yep
we will do something like that
RunService.RenderSteeped:Connect(function()
if Clone then UpdateBattery(battey) end
end)
local function UpdateBatteray(battery)
local result = nil
for i = 0, 100, 25 do
result = batteryImages[i]
if i >= battery then break end
end
if ImageLabel.Image == result then return end -- We dont need to change the image label
imageLabel.Image = result
end
and then
RunService.RenderSteeped:Connect(function()
if Clone then UpdateBattery(battery) end
end)
imageLabel:GetPropertyChangedSignal("Image"):Connect(function()
positionFlashlight:FireServer(battery ~= 0, Clone, Mouse, cam)
end)
local function UpdateBattery(battery)
local result = nil
for i = 0, 100, 25 do
result = batteryImages[i]
if i >= battery then break end
end
if ImageLabel.Image == result then return end -- We dont need to change the image label
imageLabel.Image = result
end
Mhm
um
?
positionFlashlight:FireServer(battery ~= 0, Mouse, cam)
``` so im firing this but i want to recieve this ```lua
positionFlashlight.OnClientEvent:Connect(function(toggle, cam, Mouse )
toggle is supposed to be a true / false ?
and you expect true and false ?
mhm
well yes
but no
positionFlashlight.OnClientEvent:Connect(function(player, toggle, cam, Mouse )
by default, your FireServer send the player that triggers it
so you should add it
and it should work
umm nothing is happening ingame nor in output
send full code of the local script
The one that does the UI stuff
or the one that does all of the position
Im sending both
local cam = workspace.CurrentCamera
local RS = game:GetService("ReplicatedStorage")
local RunService = game:GetService("RunService")
local Flashlight = RS.Flashlight
local gui = script.Parent
local Brightness = 3
local TS = game:GetService("TweenService")
local battery = 100
local drainRate = 0.0075
local Keybind = Enum.KeyCode.F
local UIS = game:GetService("UserInputService")
local Toggle = false
local Mouse = game.Players.LocalPlayer:GetMouse()
local TI = TweenInfo.new(.1, Enum.EasingStyle.Sine)
local imageLabel = assert(gui:FindFirstChildOfClass("ImageLabel"))
local positionFlashlight = RS.PositionFlashlight
local batteryImages = {
[0] = "rbxassetid://15657584941",
[25] = "rbxassetid://15657584759",
[50] = "rbxassetid://15657584640",
[75] = "rbxassetid://15657584517",
[100] = "rbxassetid://15657584407",
}
UIS.InputBegan:Connect(function(Input, p)
if p then return end
if Input.KeyCode == Keybind then
Toggle = not Toggle
end
end)
RunService.RenderStepped:Connect(function()
UpdateBattery(battery)
end)
imageLabel:GetPropertyChangedSignal("Image"):Connect(function()
print('agua')
positionFlashlight:FireServer(game.Players.LocalPlayer, Toggle, Mouse, cam)
end)
function UpdateBattery(battery)
local result = nil
for i = 0, 100, 25 do
result = batteryImages[i]
if i >= battery then break end
end
if imageLabel.Image == result then return end -- We dont need to change the image label
imageLabel.Image = result
print('batata')
end
``` UI ^
local RS = game:GetService("ReplicatedStorage")
local positionFlashlight = RS.PositionFlashlight
local Flashlight = RS.Flashlight
local Clone = Flashlight:Clone()
Clone.Parent = game.Players.LocalPlayer.Character
local TS = game:GetService("TweenService")
local TI = TweenInfo.new(.1, Enum.EasingStyle.Sine)
positionFlashlight.OnClientEvent:Connect(function(toggle, Mouse, cam)
print('hi')
Clone.Position = cam.CFrame.Position
TS:Create(Clone, TI, {CFrame = CFrame.lookAt(Clone.Position, Mouse.Hit.Position)}):Play()
if toggle then
TS:Create(Clone.SpotLight, TI, {Brightness = 3}):Play()
else
TS:Create(Clone.SpotLight, TI, {Brightness = 0}):Play()
end
end)
``` Positions ^
alr
and you want it triggers the event when ?
when battery change or image changes ?
like each tick ?
or each seconds ?
or each what
cause "everytime" doesnt really tell me when lol
you want the spotlight to follow the player mouse ?
yeah
?
Position is not a valid member of TweenInfo
thats normal
...
show script that does that
I had put everything server side T-T
it have nothing to do with client / server side
alr
local RS = game:GetService("ReplicatedStorage")
local TS = game:GetService("TweenService")
local flashlightUpdate = RS.FlashlightUpdate
local Flashlight = RS.Flashlight
local Clone = Flashlight:Clone()
Clone.Parent = script.Parent
flashlightUpdate.Event:Connect(function(toggle, battery, Clone, TI, Mouse, cam)
if Clone then
cam = workspace.CurrentCamera
Clone.Position = cam.CFrame.Position
TS:Create(Clone, TI, {CFrame = CFrame.lookAt(Clone.Position, Mouse.Hit.Position)}):Play()
if toggle then
TS:Create(Clone.SpotLight, TI, {Brightness = 3}):Play()
else
TS:Create(Clone.SpotLight, TI, {Brightness = 0}):Play()
end
end
end)
because you sent Clone as the tweeninfo in your event
bro why just not doing
local Players = game:GetService("Players")
local Tweens = game:GetService("TweenService")
local Run = game:GetService("RunService")
local flashLight = ... -- Instance of your flashlight
local player = Players.LocalPlayer
local mouse = player:GetMouse()
local isEnabled = true -- For when the light is on or off
local battery = 100
mouse.Moved:Connect(function()
local tween = Tweens:Create(flashLight:FindFirstChildOfClass("SpotLight"), tweenInfo, {
CFrame = CFrame.lookAt(...) -- To move your light wuth the position u want each mouse movement
})
tween:Play()
end)
Run.RenderStepped:Connect(function()
UpdateBattery(battery)
end)
local function UpdateBattery(battery)
...
if battery == 0 and isEnabled then
isEnabled = false
local tween = Tweens:Create(...) -- Brightness to 0 tween
elseif battery > 0 and not isEnabled then
local tween = Tweens:Create(...) -- Brightness to 3
end
end
follow some basic conventions
Classes, Service, Functions => PascalCase
variables => camelCase
CONSTANT_VARIABLES => SCREAMING_SNAKE_CASE
this is the one i use
Example:
local Players = game:GetService("Players") -- service
local Foo = require(...) -- class
local function DoSomething(argument) -- function
local stuff = ... -- variable
return stuff
end
local MULTIPLIER = 3 -- variable that will not change
local object = Foo.new(MULTIPLIER) -- class object (variable)
show full code
the code is too long 💀
local cam = workspace.CurrentCamera
local RS = game:GetService("ReplicatedStorage")
local RunService = game:GetService("RunService")
local gui = script.Parent
local Brightness = 3
local Flashlight = RS.Flashlight
local Clone = Flashlight:Clone()
Clone.Parent = script.Parent
local TS = game:GetService("TweenService")
local battery = 100
local drainRate = 0.0075
local Keybind = Enum.KeyCode.F
local UIS = game:GetService("UserInputService")
local Toggle = false
local isEnabled = false
local Mouse = game.Players.LocalPlayer:GetMouse()
local TI = TweenInfo.new(.1, Enum.EasingStyle.Sine)
local imageLabel = assert(gui:FindFirstChildOfClass("ImageLabel"))
local positionFlashlight = RS.PositionFlashlight
local batteryImages = {
[0] = "rbxassetid://15657584941",
[25] = "rbxassetid://15657584759",
[50] = "rbxassetid://15657584640",
[75] = "rbxassetid://15657584517",
[100] = "rbxassetid://15657584407",
}
UIS.InputBegan:Connect(function(Input, p)
if p then return end
if Input.KeyCode == Keybind then
Toggle = not Toggle
end
end)
RunService.RenderStepped:Connect(function()
UpdateBattery(battery)
end)
Mouse.Moved:Connect(function()
local tween = TS:Create(Flashlight:FindFirstChildOfClass("SpotLight"), TI, {
CFrame = CFrame.lookAt(Clone.Position, Mouse.Hit.Position) -- To move your light wuth the position u want each mouse movement
})
tween:Play()
end)
imageLabel:GetPropertyChangedSignal("Image"):Connect(function()
print('agua')
positionFlashlight:FireServer(game.Players.LocalPlayer, Toggle, Mouse, cam)
end)
function UpdateBattery(battery)
local result = nil
for i = 0, 100, 25 do
result = batteryImages[i]
if i >= battery then break end
end
if imageLabel.Image == result then return end -- We dont need to change the image label
imageLabel.Image = result
if battery == 0 and isEnabled then
isEnabled = false
local tween = TS:Create(Clone.SpotLight, TI, {Brightness = 3}) -- Brightness to 0 tween
elseif battery > 0 and not isEnabled then
local tween = TS:Create(Clone.SpotLight, TI, {Brightness = 0}) -- Brightness to 3
end
end
and it says that ???
mhm
ill check later
i rn cant help more
alright its fine thanks for helping tho
its fine
Idk why but renderstepped is bugging
@misty gyro I think ill try hardcoding it.
alr