Local Script won't change StringValue

It is parented under a ProximityPrompt.

They said its a StringValue :|||

Is it in the Workspace, perhaps?

1 Like

Localscripts dont work in workspace

So as I know you should put Client Side scripts in a place like StarterGui or something so it knows the localplayer and the whole client.

TL;DR: try parenting it inside StarterGui

1 Like

Pretty sure proximity prompts only work with scripts,

Try putting this code in to a normal Script and see if that works, as Local Scripts do not work in game.workspace.

@DoorsPro_Bacon @neviquatro So I tried both of what you said and I changed to a RemoteEvent and it still doesnt want to change the StringValue. I tried placing it into a Frame in the StarterGUI, moved the StringValue from Workspace to ReplicatedStorage but it still doesnt work.

If I edit the value from a Server Sided script it works perfectly but the catch is it is serverwide and I don’t want that value to be edited the same for everyone, I need it to be edited clientside so that it only changes for that specific person

You could try doing something like this:

Server script which when the proximity prompt is triggered, sends a :FireClient() function to a RemoteEvent.

Then, in StarterPlayerScripts, you could create a Local Script which when the remote event is fired, then changes the string value.

What?? Just put a LocalScript somewhere, maybe inside of StarterPlayerScripts, and do something like this:

workspace:WaitForChild("PromptPart").ProximityPrompt.Triggered:Connect(function()
	print("Activated")
end)
1 Like

Ah, I hadn’t thought of that. My bad

And what is this? Why are you setting a string value to “True”? Just use a BoolValue.

@Greenloop_36 @XSiggeManx Tried both of your options, and I use a StringValue because I want to add other values. But I get to think that the problem here might be that the server is only reading changes from the Server itself and that the local script doesnt gives an output to the server, thus it not changing. So I tried FireServer but still didnt work so if you or someone can help me

You don’t want it to be client sided only?

I want it to change only for the player who triggers the prompt but still to be recognized by the server so that the other script that I use for this String recognizes it as it changed

Then you should just use a server script for the whole thing. The server script can detect if a player fires the ProximityPrompt.

FireServer only works from a Local Script, and Firing clients only works from a Server script.

I would recommend creating a folder in either ReplicatedStorage or workspace with multiple values, and name them after the player’s UserIds, as having a single value for each client is quite inefficient.

I also do recommend you look up some tutorials for remote events if you’re unfamilliar with them.

That being said,

A script inside of ServerScriptService which detects when the prompt is triggered, which then edits the stringValue for the associated player in ReplicatedStorage. This is more efficient and actually less complicated than your current setup.

2 Likes

I have an idea for what you said. Thank you

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.