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

How to make an Touched function in a Local script of local parts?

Asked by 7 years ago
Edited 7 years ago

Why does my script that opperate local parts in a startergui. What is wrong with this function touched script? Local script in playergui

wait()
cam = workspace.CurrentCamera
mouse = game.Players.LocalPlayer:GetMouse()
player = game.Players.LocalPlayer

if player.leaderstats.Key.Value < 1 then
script.ACA:Clone().Parent = cam
end
------------------------------ from here --------------------
game.workspace.CurrentCamera.ACA.ABA.Touched:connect(function(part)
    if part.Parent and player.Character(part.Parent) then
        game.Lighting.Question01:Clone().Parent = player.PlayerGui
    end
end)

thank you

0
Pls do not use lighting to store things use replicated storage User#5423 17 — 7y
0
I only used Lighting for a test server ;) But thanks minetrackmania 186 — 7y

1 answer

Log in to vote
0
Answered by
3dsonicdx 163
7 years ago

You are using 'player(part.Parent)' - which you are checking if the touching object was the player and not the players character.

Change it to player.Character(part.Parent)

0
line 11: 11: attempt to call field 'Character' (a userdata value) minetrackmania 186 — 7y
Ad

Answer this question