Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Why is this not changing the Values?

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)

1 comment

0

Pls mark my answer as correct if it works plssss

1 answer

✓ Accepted answer

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)

This discussion is preserved as it was. New answers, comments, and votes are closed.