Trying to get module but i get issues with requiring it on the client

I am trying to make it so when a player clicks a button a value changes

but i am still stuck requiring this module scripts on the client but they dont work and yes i have researched

here is a sample of the error

20:05:51.577 - Stack Begin
20:05:51.578 - Script 'Players.FerbZides.PlayerGui.Trail.Choose.Green.LocalScript', Line 1
20:05:51.579 - Stack End

i don’t know why this is an issue for requiring module script on the client but i want to hear a fix on it

Code that requires it

local Module = require(game.ServerStorage:FindFirstChild("Lol"))
local plr = game.Players.LocalPlayer
script.Parent.MouseButton1Click:Connect(function()
	Module:GetTrailColorLol(plr,plr.TrailColor,8)
end)

Module Script If you need it

local Tba = {}

function Tba:GetTrailColorLol(plr, NumberValue, number) -- number is uhhh idk
	if plr then
			if NumberValue and number then
			NumberValue = number
			return NumberValue
		end
	end
end

return Tba
1 Like

Try to store the ModuleScript in ReplicatedStorage, because LocalPlayer (client) can’t see into ServerScriptService. I hope this will solve your problem.

yes it works but my value is not setting as i want it to be

Should i send a request to the server instead of modules?

  1. Do you want to set the trail color locally?
  2. Are you getting any erros?
    If so, I think you should do NumberValue.Value = number
    (as I think NumberValue is a NumberValue.

well im using DataStores and DataStores will save if the value is not nil on the server

this wont save how can i fix this i cant send an event to the server because this is a module script

never mind i can

Can you solve this?

20:32:11.916 - Value is not a valid member of Player
20:32:11.918 - Stack Begin
20:32:11.919 - Script 'ServerScriptService.Receive', Line 4
20:32:11.920 - Stack End

why is value not a valid member of player but it is set to the NumberValue :frowning:

Can you show me (us) the script, where is the error appearing?

game.ReplicatedStorage.ChangeTrail.OnServerEvent:Connect(function(plr, NumberValue, number)
	if plr then
		if NumberValue and number then
			NumberValue.Value = number
		end
	end
end)

New module code

local Tba = {}

function Tba:GetTrailColorLol(plr, NumberValue, number) -- number is uhhh idk
	if plr then
			if NumberValue and number then
			NumberValue.Value = number
			script.Parent.ChangeTrail:FireServer(plr, NumberValue, number) -- script.Parent is Replicated Storage
			return NumberValue
		end
	end
end

return Tba

ServerStorage isn’t replicated across clients.

Majority of devs just put Modules into a Folder in ReplicatedStorage or ReplicatedFirst.
You won’t have any trouble requiring it from them.

Are you sure the NumberValue is a NumberValue object? From the error it doesn’t look like it is.

its actually the TrailColor Value That is referenced as a NumberValue

Try to do print(NumberValue.ClassName) before setting the value. I’m actually wondering, what will it print out.

it print’s NumberValue the right class name which i passed from the client

Are you creating the NumberValue from client or from a server? It needs to be created from a server-sided script.

It is Server-Sided not Client-Sided

i tried fixing it

New Code

game.ReplicatedStorage.ChangeTrail.OnServerEvent:Connect(function(plr, NumberValue, number)
	if plr then
		if NumberValue and number then
			NumberValue.Value = number
			return NumberValue
		end
	end
end)

and it gives me this annoying error again

21:00:18.650 - Value is not a valid member of Player
21:00:18.654 - Stack Begin
21:00:18.656 - Script 'ServerScriptService.Receive', Line 4
21:00:18.658 - Stack End

What is the line of code which fires this on the client?

game.ReplicatedStorage.ChangeTrail:FireServer(plr,plr.TrailColor,6)

Server thinks its a player :confused:

Player is sent automatically by Roblox, you do not need to send it. Try removing the first argument and running it again.

It is received on the server as the first argument though, you just don’t need to send it on the client.

Absolute Legend

This Simple Just did it

safasga