Player Instance Boolean doesn't work on Server Side

Ight friends, Hello!
I got a bit of an issue.
Within the player character there is a boolean value that when you equip a tool it will make it true. (And then false when unequipped.) The script below works on that part. Making it true; however only on the client side.

For context: I have a Part that has a proximity prompt within it. Within that prox prompt is a script (not a local script, just a regular script) that checks if your players boolean is true; if its true it will enable the prox prompt so It can be clicked.

Before the ProximityPrompt.Triggered:Connect, is a while loop that basically checks every half a second if the boolean (within the local player) is enabled. If it is, like before stated. It will allow the prompt to be used.

All the script seems to do is enable the boolean inside the character but thats it. It doesn’t seem to work on the server. Before I had the boolean inside the game (game.Workspace.BoolValue). and the tool worked then so did the proximity prompt on the part. Idk if its just me being stupid or what.

This is the tool’s LocalScript that is enabling the Boolean within the player.
(I only added the important stuff so even though there is seemingly ‘Missing locals’ don’t fret.)

local ProximityPrompt = game.Players.LocalPlayer.EnableProximityPrompt
local tool = script.Parent
local Equipped = false
local UID = game:GetService("UserInputService")

tool.Equipped:Connect(function(plr)
anim:Play()
Equipped = true
ProximityPrompt.Value = true
end)

tool.Unequipped:Connect(function(plr)
anim:Stop()
Equipped = false
ProximityPrompt.Value = false
end)

I also have a regular server script (not a local script) within the tool as well, to set the bool to true on the server side. But that script doesnt work. This is said script:

local ProxBool = game.Players.LocalPlayer.EnableProximityPrompt

tool.Equipped:Connect(function()
	ProxBool .Value = true
	print("Server Prox On")
end)

tool.Unequipped:Connect(function()
ProxBool .Value = false
print("Server Prox Off")
SeedNumber.Value = 0
end)

I don’t know what the true issue is? My coding skills aren’t the best so if you know what’s wrong, have any help, references, solutions, or advice; It’s much appreciated :smiley:

If I also need to explain more or give more information regarding code please let me know! I believe I added everything important.

You’ll need to use a RemoteEvent to tell the server that you equipped the tool. For example, somewhere in the client you’l need to do RemoteEvent:FireServer("EquippedTool") (or something similar), and the on the server you’ll need to do RemoteEvent.OnServerEvent to detect when the event is fired. You can then change the Equipped value on the server.

Hope you find this useful :slightly_smiling_face:

Is there supposed to be a space between ProxBool and .Value ???

I hate to do this, but where would I put where? Sorry remote event confuse me. Mainly because I’m still new to em xD

I have a RemoteEvent within my replicated storage and I have locals routed to the event in each script mentioned above. I just don’t know how to correctly function them so that when the tool is equipped it’ll change the values on server & clientside :slight_smile:
I do appreciate you help! :smiley: don’t get me wrong xD

No it’s an error on my part. The name isn’t actually ProxBool. It was more specific, but for the sake of this post I shortened it to make it easier to understand :slight_smile: there is no space :slight_smile:

Use waitforchild then it should work

No, sadly it tells me “attempt to index nil with 'FindFirstChild”

I put that code within the second script (where the print statements are “Server Prox On”)
because it works fine in the Local script right above it (the first script where there is the (“UserInputService”)

Use waitforchild instead------------------

@BansonResorts local ProximityPrompt = game.Players.LocalPlayer:WaitForChild("EnableProximityPrompt") ?

You could use in a LocalScript:

tool.Equipped:Connect(function()

local Player = game.Players.LocalPlayer
game.ReplicatedStorage.(RemoteEvent):FireServer(Player, true)

end)

tool.Unequipped:Connect(function()

local Player = game.Players.LocalPlayer
game.ReplicatedStorage.(RemoteEvent):FireServer(Player, false)

end)

Script: game.ReplicatedStorage(RemoteEvent).OnServerEvent:Connect(function(Player, value)

local Equipped = Player(BoolValue)
Equipped.Value = value

end)

1 Like

@BansonResorts local ProximityPrompt = game.Players.LocalPlayer:WaitForChild("EnableProximityPrompt") ?

"attempt to index nil with ‘WaitForChild’ " :frowning:

local ProximityPrompt = game.Players.LocalPlayer:WaitForChild("EnableProximityPrompt")

Where is the value located?--------

@BansonResorts local Player = game.Players.LocalPlayer local ProximityPrompt = Player:WaitForChild("EnableProximityPrompt") ?

Its directly in the player itself. game.Players.LocalPlayer
like right with the folders such as “Backpack, PlayerGui etc”

Also remember don’t directly copy scripts from here because it can be the wrong text unicode and will turn into an error. Just type it out if didn’t.

1 Like
Does this work???
for i, Players in pairs(game.Players:GetChildren()) do
for count = 1, #Players do
for i, ProximityPrompt in pairs(game.Players:GetDescendants()) do
	local tool = script.Parent
	local Equipped = false
	local UID = game:GetService("UserInputService")

	tool.Equipped:Connect(function(plr)
		anim:Play()
		Equipped = true
		if ProximityPrompt.Name == "EnableProximityPrompt" and ProximityPrompt:isA("BoolValue") and game.Players.LocalPlayer.Name == count.Name then
			ProximityPrompt.Value = true	
		end		
	end)

	tool.Unequipped:Connect(function(plr)
		anim:Stop()
		Equipped = false
			if ProximityPrompt.Name == "EnableProximityPrompt" and ProximityPrompt:isA("BoolValue") and game.Players.LocalPlayer.Name == count.Name then
			ProximityPrompt.Value = false
		end	
	end)
		end
	end	
end	

– You will have to fix ends and ) because you didn’t give full script

I edited my comment and corrected it.

Yes! sorry for my late response I got side tracked with another duty. Thank you so much! I think I can figure it out from here on. :smiley: Thank you again!

1 Like

Sorry for my late response, Yes I got it to work. well me “I” I had help from you and others. So I just wanted to respond with a thank you! :smiley: I appreciate the assistance! :smiley:

1 Like