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

This script is supposed to copy a persons name to a String Value, but it doesn't?

Asked by 7 years ago
Edited 7 years ago

Basically when you click a button it saves your name to a String Value but it doesn't

local canspawn = script.Parent.CanSpawn

script.Parent.ClickDetector.MouseClick:connect(function(clicked)
    if canspawn.Value == true then
        local newrocket = game.ReplicatedStorage["Suicide Rocket"]:Clone()
        newrocket.Parent = game.Workspace
        newrocket:MoveTo(Vector3.new(-11.289, 1.092, 4.096))
        newrocket.Name.Value = clicked
        canspawn.Value = false
    end
end)

The error is: Workspace.Spawn A Rocket!.Head.Spawner:8: attempt to index field 'Name' (a string value)

0
dude.... it is suppose to be either newrocket.Name or newrocket.Value greatneil80 2647 — 7y
0
It's newrocket.Value not newrocket.Name.Value Drakyoid 0 — 7y
0
I found out why it isn't working now. There is a string value in the clone called Name but the script is getting confused on which one to go by. But thank you all for your awnsers! Thelegendofglitcher2 49 — 7y
0
Why make a value in the world if you can just make a variable for the script? hiimgoodpack 2009 — 7y
0
Well I have two scripts that communicate with each other, if I had a variable, the other script wouldn't be able to read it. Thelegendofglitcher2 49 — 7y

1 answer

Log in to vote
0
Answered by 7 years ago

You're trying to access a string value's non-existing string value.

newrocket.Name.Value

Names don't have values or properties. They're just strings. If you only want to access a path to the name just remove .Value. Otherwise, take off .Name.

If you want it to put the value as the player's name then set the .Value not that incorrect way of accessing Value.

Ad

Answer this question