i get this is a very newbie question but how would i get this to work for another part touching the one with the script instead of requiring a player to touch it
local Part = script.Parent
local Sword = game.Workspace.Ghostwalkers.FlyingGhostwalker
local function fade()
Sword.Transparency = 1
end
Sword.Touched(fade)
Edit: i should probably go more in depth on what im trying to accomplish
Im trying to make the moving sword object (a Model and Mesh) so that when it passes the white rectangle (Script block) it becomes transparent
Thank you for the help but either the solutions posted either dont work for moving models
(or meshes?) or im doing something wrong
local Sword = script.Parent
Sword.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
hit.Transparency = 1--If, you wannt it to make the part transparent then do Scriot.Parent!
print(hit.Name)--if, you wann't it to print your name , then do hit.Parent.Name!
end
end)
-- Fade function
local function fadeObjectTransparency(objectToFade)
local tweenInfo = TweenInfo.new(0.2, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut, 0, false, 0)
local tweenGoal = {Transparency = 0.3}
local tween = game:GetService("TweenService"):Create(objectToFade, tweenInfo, tweenGoal)
end
-- Touch object to activate fade
local myObject = game.Workspace.Ghostwalkers.FlyingGhostwalker -- optionally make the Touched its own function, and run it for a folder using a for-loop if you have many "fade touchers" objects
local debounce = false
myObject.Touched:Connect(function(toucher)
if debounce then return end
if not toucher("BasePart") then return end
objectToFade(toucher)
end
anyway the players hand might become invisible too so to avoid that (i mean who wants invisible hands) put this code inside touched
if game.Players:GetPlayerFromCharacter(toucher.Parent) then return end