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

Why is this not changing the Values?

Asked by 2 years ago
Edited 2 years ago

this is in a local script in a tool. the Name X Y and Z values do not change in replicated storage.

RepStore = game:GetService("ReplicatedStorage")
X = RepStore.X.Value
Y = RepStore.Y.Value
Z = RepStore.Z.Value
Name = RepStore.Name.Value


local function onActivate()
    local Part = Mouse.Target
    if Part.Parent == workspace.Plot then
        X = Mouse.Target.Position.X
        Y = Mouse.Target.Position.Y
        Z = Mouse.Target.Position.Z
        Name = Mouse.TargetSurface.Name
    end
end

tool.Activated:Connect(onActivate)

0
Pls mark my answer as correct if it works plssss AlexanderYar 788 — 2y

1 answer

Log in to vote
0
Answered by 2 years ago
Edited 2 years ago

It won't change them because your not setting the values, your setting the variable.

Var1 = "a"
Var1 = "b"

This is an obvious example of this. An example like your situation is

numvalue.Value = 2

Var1 = numvalue.Value 
Var1 = 1

Print(Var1) -- prints 1
Print(numvalue.Value) -- prints 2

To fix this, just don't use a variable for the value, use the variable for the instance and SET the value. So do this

RepStore = game:GetService("ReplicatedStorage")
X = RepStore.X
Y = RepStore.Y
Z = RepStore.Z
Name = RepStore.Name


local function onActivate()
    local Part = Mouse.Target
    if Part.Parent == workspace.Plot then
        X.Value = Mouse.Target.Position.X
        Y.Value = Mouse.Target.Position.Y
        Z.Value = Mouse.Target.Position.Z
        Name.Value = Mouse.TargetSurface.Name
    end
end

tool.Activated:Connect(onActivate)

Ad

Answer this question