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

Server script fails to do its part? (FilteringEnabled, RemoteEvent)

Asked by
Razurix 10
9 years ago

Information about locations of objects used; Local script (Client script) -- Inside PlayerGui. Script (Server script) -- Inside ReplicatedFirst, as a child of another Script. RemoteEvents (Folder) -- Inside Workspace. CustomerEvent (RemoteEvent) -- Inside Workspace, as a child of RemoteEvents (Folder)

LocalScript

local CustomerBusy = false

for i,v in pairs(game.Workspace:GetChildren()) do
if v:IsA("Model") and v.Name == "HotelConsole" and v:FindFirstChild("CustomerConsole") then
print("Console found")
v.CustomerConsole.CD.MouseClick:connect(function(plr)
print("Console clicked!")
local Cash = plr.PlayerGui:WaitForChild("Stats").Cash
if CustomerBusy == false and Cash.Value >= 500 and plr.PlayerGui.Stats.AwaitingConfirmation.Value ~= true and plr.PlayerGui.Stats.PlayerHasRoom.Value ~= true then
print("Passed test!")
CustomerBusy = true
v.SellerConsole.Beep:Play()
print("Play beep!")
game.Workspace.RemoteEvents.CustomerEvent:FireServer(v)
print("Sent request to server!")
CustomerBusy = false
print("End")
end
end)
end
end

Local script prints all the way up to "print("End")" Local script IS working. Issue seems to be the Server script..

Server Script

local CustomerBusy = false

game.Workspace.RemoteEvents.CustomerEvent.OnServerEvent:connect(function(plr, model)
print("Event detected")
if CustomerBusy == false then
CustomerBusy = true
plr.PlayerGui.Stats.AwaitingConfirmation.Value = true
model.CustomerConsole.CD.MaxActivationDistance = 0
model.CustomerConsole.CustomerName.Value = plr.Name
model.SellerConsole.BrickColor = BrickColor.new("Lime green")
model.SellerConsole.CD.MaxActivationDistance = 15
end
end)

Does not print "print("Event detected")"

Help?

1 answer

Log in to vote
1
Answered by
adark 5487 Badge of Merit Moderation Voter Community Moderator
9 years ago

Very simple, Scripts don't run in ReplicatedFirst. Put them either in the Workspace, or in ServerScriptService.

As a side note, it's probably a little more organized to put your "RemoteEvents folder" inside the ReplicatedStorage service instead of Workspace.

0
Well, the script works now, but "Stats is not a valid member of PlayerGui" .. I remember a friend mentioning you can't access a player's playergui with FE.. how can I get around this? Razurix 10 — 9y
1
It's not an easy problem to get around if you're trying to use the ValueObjects: they're inherently unsafe. What you *can* do is maintain a Table list of all Players and what their stored data is (aka - AwaitingConfirmation) on the Server, and each player specifically on their own Client using the ValueObjects you already have set up. adark 5487 — 9y
0
I figured out a solution, relatively simple actually.. xD game.Players.PlayerAdded:connect(function(plr) local stats = game.ReplicatedStorage:WaitForChild("Stats"):Clone() stats.Name = plr.Name stats.Parent = game.ReplicatedStorage end) Razurix 10 — 9y
Ad

Answer this question