Log in to vote
0

# Can I get some help with this error that's causing my mind to fracture?

Asked by 10 days ago

I keep getting an error on a line of code that should change a string value to the name of a part, and it makes no sense to me please help.

here's my script (Its only a small part of it to keep it simple, but i assure you everything else works):

UIS.InputEnded:Connect(function(input)
if input.KeyCode == Enum.KeyCode[pickupkey] then
if mouse.Target then
if mouse.Target:FindFirstChild("Pickable") then
local item = mouse.Target
if item then
local distanceFromItem = player:DistanceFromCharacter(item.Position)
if distanceFromItem < 7 then
-- we fill this in loadstring
print("worked")
game.ReplicatedStorage.Name.Value = item --HERES WERE THE ERROR POINTS OUT
PickupItem:FireServer(item)
end
end
end
end
end
end)


the error says: Players.Paczki_TCBC.PlayerScripts.LocalScript:35: attempt to index string with 'Value'

Please help dude, my head hurts.

### 3 answers

Log in to vote
0
Answered by 10 days ago

You cant name something 'Name' because 'Name' is a property of ReplicatedStorage. game.ReplicatedStorage.Name is 'ReplicatedStorage' so it doesn't go to the string value you want.

0
You would need to change the name of your string value. BulletproofVast 385 — 10d
Log in to vote
0
Answered by
NGC4637 245
10 days ago

do this instead:

UIS.InputEnded:Connect(function(input)
if input.KeyCode == Enum.KeyCode[pickupkey] then
if mouse.Target then
if mouse.Target:FindFirstChild("Pickable") then
local item = mouse.Target
local distanceFromItem = player:DistanceFromCharacter(item.Position)
if distanceFromItem < 7 then
print("worked")
game.ReplicatedStorage:FindFirstChild("Name").Value = item.Name
PickupItem:FireServer(item)
end
end
end
end
end)


basically I changed the errored line to item.Name instead of item

Log in to vote
0
Answered by 10 days ago

Your code:

UIS.InputEnded:Connect(function(input)
if input.KeyCode == Enum.KeyCode[pickupkey] then
if mouse.Target then
if mouse.Target:FindFirstChild("Pickable") then
local item = mouse.Target
if item then
local distanceFromItem = player:DistanceFromCharacter(item.Position)
if distanceFromItem < 7 then
-- we fill this in loadstring
print("worked")
game.ReplicatedStorage.Name.Value = item --HERES WERE THE ERROR POINTS OUT
PickupItem:FireServer(item)
end
end
end
end
end
end)


Line 11:

game.ReplicatedStorage.Name.Value = item


you have to change the value named "Name" because the Script thinks you renaming the ReplicatedStorage. Get it now? LOL gotta read your own code lol