Well, I recently made a datastore, but it runs for all players, and the title came to mind, the value of the string value, change the stringValue for other scripts, for example, the value is “High”, the script detects that value, and does its function, and if it comes out “Medium”, it does a different function
What do you need help with in regards to this?
I need it to detect a function between the three and run the script
Do you need help in some kind of script, for example if the Value “G” was triggered, you need to detect it?
Yes, but I’m wrong, instead of “G” It is High, Medium, Low, It depends on the previous three, part of the script will be executed
If you are trying to detect a player if they are triggering that Value, well possibly you can find a way to detect it, by using the String Value, or others. (If I’m incorrect, I’m deeply sorry as I’m just like 3 month in Roblox Studio.)
HAHAHA, I’ve been in roblox studio for 3 years and I hardly learned anything, But hey, I mean a StringValue
To get the value of a string value do: StringValueObject.Value
Edit: Here is a sample if
statement.
if StringValueObject.Value == "High" then
Hey, it doesn’t work, is there a bug?
local StringValueObject = game.Players.LocalPlayer:WaitForChild("Graficos"):WaitForChild("Shadow")
local Lighting = game:GetService("Lighting")
if StringValueObject.Value == "Bajo" then
Lighting.GlobalShadows = false
Lighting.ShadowSoftness = 1
for _, item in ipairs(workspace:GetDescendants()) do
if item:IsA("PointLight") then
item.Shadows = false
item.Brightness = 0.35
end
end
end
if StringValueObject.Value == "Medio" then
Lighting.GlobalShadows = true
Lighting.ShadowSoftness = 0.5
for _, item in ipairs(workspace:GetDescendants()) do
if item:IsA("PointLight") then
item.Shadows = false
item.Brightness = 0.35
end
end
end
if StringValueObject.Value == "Alto" then
Lighting.GlobalShadows = true
Lighting.ShadowSoftness = 0.1
for _, item in ipairs(workspace:GetDescendants()) do
if item:IsA("PointLight") then
item.Shadows = true
item.Brightness = 0.75
end
end
end
Is this a server script or a local script?
It’s a Local Script, if it’s a normal one, it runs for everyone and I just want it to run for just one
Are any of the values lowercase, keep in mind the if statements are case sensitive. Also is there any errors being logged in the output/F9 console and have you tried simple debugging?
You would have to use the.changed event to detect when it changed:
local StringValueObject = game.Players.LocalPlayer:WaitForChild("Graficos"):WaitForChild("Shadow")
local Lighting = game:GetService("Lighting")
StringValueObject.Changed:Connect(function()
if StringValueObject.Value == "Bajo" then
Lighting.GlobalShadows = false
Lighting.ShadowSoftness = 1
for _, item in ipairs(workspace:GetDescendants()) do
if item:IsA("PointLight") then
item.Shadows = false
item.Brightness = 0.35
end
end
end
if StringValueObject.Value == "Medio" then
Lighting.GlobalShadows = true
Lighting.ShadowSoftness = 0.5
for _, item in ipairs(workspace:GetDescendants()) do
if item:IsA("PointLight") then
item.Shadows = false
item.Brightness = 0.35
end
end
end
if StringValueObject.Value == "Alto" then
Lighting.GlobalShadows = true
Lighting.ShadowSoftness = 0.1
for _, item in ipairs(workspace:GetDescendants()) do
if item:IsA("PointLight") then
item.Shadows = true
item.Brightness = 0.75
end
end
end
end)