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

Two scripts work perfectly fine in a local test, but not with filtering enabled???

Asked by
1VoyX 5
6 years ago
Edited 6 years ago

I'm making a GUI button that when pressed converts a currency called "etherium" into cash. Problem is, the scripts work perfectly fine in a local test but once I go into a filtering enabled environment they fail to work. Etherium is stored in a folder inside of the player, and cash is in the server storage.

--This is the local script inside of a button

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local EthTransfer = ReplicatedStorage:WaitForChild("EtheriumTransferService")

function onClick()
local p = game.Players.LocalPlayer
EthTransfer:FireServer(p)
script.Parent.Parent.Parent.Parent.Parent.Parent.Parent.Parent.Cash:Play()
end

script.Parent.MouseButton1Down:connect(onClick)
--This is the script inside workspace
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local EthTransfer = Instance.new("RemoteEvent", ReplicatedStorage)
EthTransfer.Name = "EtheriumTransferService"

local function onEthFired(localPlayer)
print("recieved event")
local eth = localPlayer.EtheriumCount.Etherium
local Stats = game.ServerStorage.PlayerMoney:FindFirstChild(localPlayer.Name)
local addition = eth.Value * 10
Stats.Value = Stats.Value + addition
eth.Value = 0
print("event completed")
end

EthTransfer.OnServerEvent:Connect(onEthFired)
0
Borderlands? Also "i before e, except after c" looool. Anyways, the problem is that you're are creating a new RemoteEvent with your localscript. What?! The point of FE is that no changes made by localscripts will be replicated to the server. Just have "EtheriumTransferService" made by the server script are already created by default. ScrewDeath 153 — 6y

1 answer

Log in to vote
1
Answered by
CPF2 406 Moderation Voter
6 years ago

The answer is that you need put these lines

local EthTransfer = Instance.new("RemoteEvent", ReplicatedStorage)
EthTransfer.Name = "EtheriumTransferService"

into the server script. When you create the remote event on the localscript, it's local, so the server can't find it, and yields forever.

0
Also note if you care about efficiency, don't format Instance.new(obj, parent), format it like EthTransfer = Instance.new(obj); (next line) EthTransfer.Parent = ReplicatedStorage. climethestair 1663 — 6y
0
No actually, its more efficiant to do (obj, parent) uhTeddy 101 — 6y
Ad

Answer this question