#When cloning from replicated storage+parenting it to the workspace it isnt detected by touch script

1 messages · Page 1 of 1 (latest)

torpid reef
#
local tool = script.Parent
local handle = tool.Handle
local hitbox = tool.Hitbox
local repstorage = game:GetService("ReplicatedStorage")
local coal = repstorage.Coal
local player = game.Players.LocalPlayer
local character = player.Character
local humanoid = character:WaitForChild("Humanoid")
local debounce = false

local hitboxTouchedConnection = nil

tool.Activated:Connect(function(on)
    if debounce then return end
    debounce = true
    hitbox.CanTouch = true

    if (hitboxTouchedConnection~=nil) then
        hitboxTouchedConnection:Disconnect()
    end

    hitboxTouchedConnection = hitbox.Touched:Connect(function(hit)
        if hit.Name == "CoalOre" then
            print("MINE")
            local clone = coal:Clone(1)
            clone.Parent = player:FindFirstChild("Backpack")
            clone.Handle.CanTouch = true
            hitbox.CanTouch = false
            task.wait(1)
            debounce = false
        else
            return false;
        end
    end)

end)

^^ clone script

do i need to like repeatedly check for it or something?

gritty lodge
#

Touched is only activated when something physically moves. Spawning it in won't activate the event

torpid reef
#
local part = script.Parent
local folder = game.Workspace:FindFirstChild("Generator")
local signal1 = folder.Powersignal1
local signal2 = folder.Powersignal2
local signal3 = folder.Powersignal3
local signal4 = folder.Powersignal4
local fire = part.Parent.Flame
local x = 0
local debounce = false

part.Touched:Connect(function(hit)
    print(hit)
    if hit.Parent.Name == "Coal" then
        hit.Parent:Destroy()
        part.Flame:Play()
        fire.FireParticles.Enabled = true
        fire.Transparency = 0.7
        x = x+1
        print(x)
        task.wait(2)
        part["Flames Loop"]:Play()
        fire.FireParticles.Rate = 15
        fire.SpotLight1.Enabled = true
        fire.SpotLight2.Enabled = true
        fire.embers.Enabled = true
        fire.Transparency = 0.3
        if x>=5 then
            print("x >= 5")
            signal1.Material = "Neon"
            signal2.Material = "Neon"
            signal3.Material = "Neon"
            signal4.Material = "Neon"
        elseif x>=4 then
            print("x >= 4")
            signal4.BrickColor = BrickColor.new("Lime green")
        elseif x>=3 then
            print("x >= 3")
            signal3.BrickColor = BrickColor.new("Lime green")
        elseif x>=2 then
            print("x >= 2")
            signal2.BrickColor = BrickColor.new("Lime green")
        elseif x>=1 then
            print("x >= 1")
            signal1.BrickColor = BrickColor.new("Lime green")
        end
    end
end)

this is the touch detector script thing

gritty lodge
torpid reef
#

then its detected

#

well it SHOULD BE detected but

#

it isnt

#

every other part works though

#

including if i just put the one in repstorage into workspace and equip it like that

gritty lodge
# torpid reef here

Watch the volume next time. Didn't appreciate my ear drums being ruptured.

Does the tool have CanTouch enabled?

gritty lodge
# torpid reef yeah it does

and coal is the tool? Because the one you picked up seems to work, not the one currently in your inventory.

gritty lodge
# torpid reef yea

It looks like you only connect to the hitbox if you activate the tool (which means use the tool)

torpid reef
#

wdym

#

i didnt activate eithero

gritty lodge
torpid reef
#

second one is the one that detects it

#

it doesnt detect it when cloned from replicated storage

#

but when i copy paste the repstorage one and put it into workspace, THEN play it works

gritty lodge
torpid reef
#

yes

gritty lodge
torpid reef
#

mb i tried to explain thru the title and wouldve went more in detail but i was fetching the touch detect script

gritty lodge
#

Why did you give "1" to the :Clone function?

Is that Touched event firing at all? The one within the tool? Can you add a print to the top of the script to make sure it's running?

sly trail
#

client is cloning the coal on their end and its not replicated to the server

#

have the server do the cloning and stuff, keep things like resources out of replicated storage or exploiters can just give themselves 5 million coal

gritty lodge
torpid reef
torpid reef
torpid reef
sly trail
#

keep it in serverstorage, where the client cant access it

#

look up remote events and use them to ask the server if you can have a coal

#

then the server determines if they should have a coal or not and gives it to them

torpid reef
#

brain gonna be fried but that's how I learnt up to now so