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

Why isn't the String Value changing?

Asked by 5 years ago
Edited 5 years ago

script 1:

local ship = workspace.Ship
local value = workspace.Value.Value

if value == 'intermission' then
    local new = ship:Clone()
    new.Parent = game.ServerStorage
    value = 'ready'
end 

if value == 'regening' then
    local shipclone = game.ServerStorage.Ship
    local map = shipclone
    map.Parent = workspace
    value = 'intermission'
end

script 2:

local ship = script.Parent
local value = workspace.Value.Value
local PP = script.Parent.PrimaryPart
local explosion = workspace.Explosion
local sinking = workspace["Ship Sink 1"]
local wave = workspace["Ocean wave sound effects [HD]"]
workspace["Titanic Grand Staircase Ambiance "]:Play()
wave:Play()

function sink()
    value = 'sinking'
    --private scripting
end
value = 'regening'

if value == 'ready' then
    wait(60)
    sink()
end

Pls help

0
Please explain your problem a bit more! BashGuy10 384 — 5y
0
Well, i have 2 scripts: the one that sinks the ship (i dont want it leaked) and this one. This one is the regeneration script. I need the value to change so that i could see when something is supposed to change, but it doesnt change. Help. MradmannMvip 50 — 5y
1
what kind of scripts and also for script 1 I recommend you try changing the name of Value to something else because workspace.Value doesn't exist. change the name of the stringvalue then try... Also change Value to local value = workspce.value instead of workspace.Value.Value greatneil80 2647 — 5y
0
i will try that. MradmannMvip 50 — 5y

1 answer

Log in to vote
0
Answered by
BashGuy10 384 Moderation Voter
5 years ago
Edited 5 years ago

You want to use Changed on problems like this.

Only use Changed on values like Stringvalue or intvalues

local ship = workspace.Ship
local value = workspace.Value

value.Changed:Connect(function() -- ONLY USE CHANGED FOR STRINGVALUES, OBJECTVALUES, INTVALUES AND NUMBERVALUE, CFRAMEVALUES
    if value.Value == 'intermission' then
        local new = ship:Clone()
        new.Parent = game.ServerStorage
        value.Value = 'ready'
    elseif value.Value == 'regening' then
        local shipclone = game.ServerStorage.Ship
        local map = shipclone
        map.Parent = workspace
        value.Value = 'intermission'
    end 

end)

Script 2:

local ship = script.Parent
local value = workspace.Value.Value
local PP = script.Parent.PrimaryPart
local explosion = workspace.Explosion
local sinking = workspace["Ship Sink 1"]
local wave = workspace["Ocean wave sound effects [HD]"]
workspace["Titanic Grand Staircase Ambiance "]:Play()
wave:Play()
function sink()
    value = 'sinking'
    --private scripting
    wait(100) -- Change this to how long you think it should sink for
    value.Value = 'regening'
end




value.Changed:Connect(function()
if value.Value == 'ready' then
    wait(60)
    sink()
end
end)

If this helped, please mark this as the answer

0
alright, to the testing! MradmannMvip 50 — 5y
0
Most important thing when using code from answers: TESTING! BashGuy10 384 — 5y
0
no, didnt work, sorry. MradmannMvip 50 — 5y
0
edited BashGuy10 384 — 5y
View all comments (3 more)
0
still didnt work MradmannMvip 50 — 5y
0
i have no idea. BashGuy10 384 — 5y
0
also that "wait" you put in is not necessary as the regening thing is at the end of the function, and thats when the ship stops sinking. MradmannMvip 50 — 5y
Ad

Answer this question