So i’m trying to make something that when the value of a bool is 1 that an error gets shown.(the error is an txt label within startergui)
But that doesn’t works and I have no clue why it doesn’t works. And in case your wondering im tweening the label. Cause if I only had to make it visible then I wouldn’t have made this topic.
I really would appreciate it if someone is going to help me with this!
The one that checks if the value is 1; (this one is server-sided connected with remote function)
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local tvRequest = Instance.new("RemoteFunction")
tvRequest.Parent = ReplicatedStorage
tvRequest.Name = "CreateOldTvRequest"
local function tvRequestFunction(player)
local Cash = player:WaitForChild("leaderstats"):WaitForChild("Cash")
local leaderstats = player.leaderstats
print(Cash.Value)
if Cash.Value >= 0 then
Cash.Value -= 0 --Subtract 0 from the Player's Cash
local oldtvclone = game.ReplicatedStorage.Tvs.OldTv.PartsOfOldTv:Clone()
oldtvclone.Parent = game.Workspace
oldtvclone.Name = "OldTvClone"
print(oldtvclone)
print(oldtvclone.Parent)
for i, v in pairs(oldtvclone:GetChildren()) do
v.CanCollide = true
v.Transparency = 0
v.Anchored = false
end
local value = Instance.new("BoolValue")
value.Name = "PackageChecker"
value.Parent = game.Workspace:WaitForChild("OldTvClone")
local tv = game.Workspace:WaitForChild("OldTvClone")
local checker = game.Workspace.Packages
if tv and checker.Value == 0 then
wait(5)
print("<\\-")
tv:Destroy()
local tvPackage = game.ReplicatedStorage.Packages.PackagesConveyor.OldTvSellingBox:Clone()
tvPackage.Parent = game.Workspace
tvPackage.Name = "OldTvPackage"
checker.Value = 1
if tv and checker.Value == 1 then
-- don't know what to put here yet....
end
end
else
print("You don't have enough cash")
end
end
tvRequest.OnServerInvoke = tvRequestFunction
All events require that syntax to be able to “listen” for them. I don’t think there’s any way to connect two separate scripts without any kind of event, whether that be a bindable event, property changed event, etc. Events are how scripts communicate.
Remote events and remote function is to connect client to server and server to client. You can use stringValues or intValues. Also you can use moduleScripts and bindable event and bindable functions.
It looks like you have a server script, and you want the client to be able to “respond” to something in the server script. This is impossible without remote events/functions or replicated objects (such as value objects, and even then would require property changed events), since the only things the client sees are replicated objects (in workspace or replicatedStorage), and as such those objects are the only way to “communicate” between client and server scripts.
I’d suggest making a remote event for each player, having the player’s local script listen for its fire, and have the server fire the event with the information you want the client to see, such as “1”.
Isn’t that unnecessary? Cause I put the value there so it can check if the value is one if so then the error needs to pop up. So all I need to know is how I can make the server-script connecting to the localscript in the PlayerGui.
And if I use remote functions it needs built-in functions am I right or am I totally wrong? If i’m right is there an other way to connect them cause I don’t need functions like PlayerAdded or MouseButton1Click.
You probably don’t need to use remote functions in this case, events should be enough. You can use value objects like I said before since they would be replicated in workspace or replicatedstorage, but even then you have to connect the client’s script to the value object’s PropertyChangedEvent, and is definitely less performant than just using events (although probably not by much).
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local tvRequest = Instance.new("RemoteFunction")
tvRequest.Parent = ReplicatedStorage
tvRequest.Name = "CreateOldTvRequest"
local function tvRequestFunction(player)
local Cash = player:WaitForChild("leaderstats"):WaitForChild("Cash")
local leaderstats = player.leaderstats
print(Cash.Value)
if Cash.Value >= 0 then
Cash.Value -= 0 --Subtract 0 from the Player's Cash
local oldtvclone = game.ReplicatedStorage.Tvs.OldTv.PartsOfOldTv:Clone()
oldtvclone.Parent = game.Workspace
oldtvclone.Name = "OldTvClone"
print(oldtvclone)
print(oldtvclone.Parent)
for i, v in pairs(oldtvclone:GetChildren()) do
v.CanCollide = true
v.Transparency = 0
v.Anchored = false
end
local value = Instance.new("BoolValue")
value.Name = "PackageChecker"
value.Parent = game.Workspace:WaitForChild("OldTvClone")
local tv = game.Workspace:WaitForChild("OldTvClone")
local checker = game.Workspace.Packages
if tv and checker.Value == 0 then
wait(5)
print("<\\-")
tv:Destroy()
local tvPackage = game.ReplicatedStorage.Packages.PackagesConveyor.OldTvSellingBox:Clone()
tvPackage.Parent = game.Workspace
tvPackage.Name = "OldTvPackage"
checker.Value = 1
if tv and checker.Value == 1 then
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")
local remoteEvent = ReplicatedStorage:WaitForChild("RemoteEventTest")
remoteEvent:FireClient(player)
end
end
else
print("You don't have enough cash")
end
end
tvRequest.OnServerInvoke = tvRequestFunction
But how does the local script needs to be? Cause I already have this putten in it;(this script is in the error gui btw)