althruist
(althruist)
August 25, 2021, 12:34pm
#1
Hi, devs,
I have some issues (again) but this time it’s a little different. I have been trying to make a light accessory that is given once a player enter a tunnel (by hitting the doorway)
It supposingly stays put on the left side of the player. The light should be shining on the wall. But instead, this happens:
https://i.imgur.com/73dDOVH.mp4
(Don’t mind the poor framerate)
This is the code:
local light = game.ServerStorage.light
script.Parent.Touched:Connect(function(hit)
local hasgot = hit.Parent:FindFirstChild("BoolValue")
lighting.Atmosphere.Color = Color3.fromRGB(97, 97, 97)
if hasgot == nil then
if hit.Parent:FindFirstChild("Humanoid") then
hit.Parent.Humanoid:AddAccessory(light:Clone())
local got = Instance.new("BoolValue",hit.Parent)
wait(10)
end
end
end)
Any help please?
Thanks,
Aki
Is the light anchored? That’s the main issue I would expect. (to be clear game.ServerStorage.light)
althruist
(althruist)
August 25, 2021, 12:37pm
#3
If I do anchor, the thing would just stay in one place and does not move with the player. I’ll try again just in case.
Oh, you want it to follow the player?
Can’t you lerp or tween it to the player? (or welding, or attachments… etc)
Qinrir
(Quin)
August 25, 2021, 12:38pm
#5
in that case welding is the thing
althruist
(althruist)
August 25, 2021, 12:39pm
#6
It does have this but it doesn’t do anything.
althruist
(althruist)
August 25, 2021, 12:40pm
#7
I tried inserting a weld but it obviously won’t work because I have nothing to attach it to.
Is there another one? Are they connected?
Anyways, I would suggest weld for static following or tween/lerp for dynamic movement
althruist
(althruist)
August 25, 2021, 12:41pm
#9
I think if it was dynamic it would be better but I am incapable of doing these things so I might have to stick around with weld or something.
Qinrir
(Quin)
August 25, 2021, 12:41pm
#10
Just Do Weld By Using A Simple Script:
script.Parent.Equipped:Connect(function()
local weld = instance.new("Weld",script.Parent.Parent.RightHand)
weld.Part1 = script.Parent.Parent.RightHand
weld.Part0 = script.Parent
end)
I Am Sure The Light Is A Tool Just Put this script in a script in the tool
Well, try welding first, and if you want to go further on later, play with TweenService.
althruist
(althruist)
August 25, 2021, 12:43pm
#12
I may have forgot to mention that it’s an accessory.
It isn’t a tool. It’s an accessory, that’s why it doesn’t work (accessories dont have Equipped)
Qinrir
(Quin)
August 25, 2021, 12:44pm
#14
oh so its not a tool great what type of object is it doe
Qinrir
(Quin)
August 25, 2021, 12:44pm
#15
Oh Yea I thought it was a tool
althruist
(althruist)
August 25, 2021, 12:44pm
#16
It’s an accessory… and a part with light inside.
althruist
(althruist)
August 25, 2021, 12:45pm
#17
My fault, I forgot to mention that it was.
Qinrir
(Quin)
August 25, 2021, 12:45pm
#18
Just Changed The Equipped To This:
script.Parent:GetPropertyChangedSignal("Parent"):Connect(function()
local weld = instance.new("Weld",script.Parent.Parent.RightHand)
weld.Part1 = script.Parent.Parent.RightHand
weld.Part0 = script.Parent
end)
Parent The Script To The Accessory
instance.new should be Instance.new
althruist
(althruist)
August 25, 2021, 12:50pm
#20
It still didn’t work…
script.Parent:GetPropertyChangedSignal("Parent"):Connect(function()
local weld = Instance.new("Weld",script.Parent.Parent.Head)
weld.Part1 = script.Parent.Parent.Head
weld.Part0 = script.Parent
end)